3e71699b8e97a1c9605f82ab5805bd8e84472584 — Steve Gattuso 6 months ago 6fe81e2
add initial delete endpoint
M feedon/blueprints/auth.py => feedon/blueprints/auth.py +11 -0
@@ 108,3 108,14 @@ def complete():
    session['user_id'] = user.id

    return redirect('/')

@bp.route('/delete', methods=['GET'])
def delete_account():
    if request.args.get('confirm') != 'yes':
        return render_template('auth/delete.html')


    flash('You are now logged out and all of your account\'s data has been deleted from the database. It was fun while it lasted!')
    return redirect('/')

M feedon/db/__init__.py => feedon/db/__init__.py +3 -0
@@ 30,6 30,9 @@ class User(peewee.Model):

    def instance_url(self, url):
        return f"https://{self.instance_domain}{url}"
    def delete_account(self):
        return self.delete_instance(recursive=True)

    class Meta:
        table_name = 'users'

A feedon/templates/auth/delete.html => feedon/templates/auth/delete.html +12 -0
@@ 0,0 1,12 @@
{% extends "layouts/main.html" %}

{% block content %}
<h2>Delete your account</h2>
  Are you sure you wish to delete your account? This action will delete all data associated with your account from the database and is irreversible.
  <a href="/auth/delete?confirm=yes">Yeah, let's do it</a> or
  <a href="/">No thanks</a>.
{% endblock %}

M feedon/templates/timelines/index.html => feedon/templates/timelines/index.html +3 -0
@@ 17,6 17,9 @@
    timeline URLs may have been compromised, you may generate a new URL by
    clicking on the ↻ button.
      Lastly, if you've had enough of this and want out: <a href="/auth/delete">click here</a> to delete your account and all associated data from the database.
  <div class="timelines">
      {% for timeline in timelines %}
          <div class="timeline">