aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2020-08-26 23:36:08 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2020-08-26 23:36:08 +0200
commitf5ec27f6fd5a2262e3429a874857f0f4517e38a1 (patch)
tree5319c3c15ca06e9aa0e78dee0052d31ad82149b2
parentMerge branch 'master' of git.sr.ht:~cedric/newspipe (diff)
downloadnewspipe-f5ec27f6fd5a2262e3429a874857f0f4517e38a1.tar.gz
newspipe-f5ec27f6fd5a2262e3429a874857f0f4517e38a1.tar.bz2
newspipe-f5ec27f6fd5a2262e3429a874857f0f4517e38a1.zip
fixed self deletion of account.
-rw-r--r--newspipe/templates/profile.html2
-rw-r--r--newspipe/web/views/session_mgmt.py6
-rw-r--r--newspipe/web/views/user.py2
3 files changed, 7 insertions, 3 deletions
diff --git a/newspipe/templates/profile.html b/newspipe/templates/profile.html
index edbae368..12517331 100644
--- a/newspipe/templates/profile.html
+++ b/newspipe/templates/profile.html
@@ -61,7 +61,7 @@
<br />
<div class="row">
<div class="col">
- <a href="/delete_account" class="btn btn-warning" onclick="return confirm('{{ _('You are going to delete your account.') }}');">{{ _('Delete your account') }}</a>
+ <a href="{{ url_for('user.delete_account') }}" class="btn btn-warning" onclick="return confirm('{{ _('You are going to delete your account.') }}');">{{ _('Delete your account') }}</a>
</div>
</div>
</div><!-- /.container -->
diff --git a/newspipe/web/views/session_mgmt.py b/newspipe/web/views/session_mgmt.py
index 4fab943f..5e0ac64d 100644
--- a/newspipe/web/views/session_mgmt.py
+++ b/newspipe/web/views/session_mgmt.py
@@ -1,6 +1,7 @@
import logging
from datetime import datetime
+from werkzeug.exceptions import NotFound
from flask import (
current_app,
flash,
@@ -56,7 +57,10 @@ def on_identity_loaded(sender, identity):
@login_manager.user_loader
def load_user(user_id):
- return UserController(user_id, ignore_context=True).get(id=user_id, is_active=True)
+ try:
+ return UserController(user_id, ignore_context=True).get(id=user_id, is_active=True)
+ except NotFound:
+ pass
@current_app.before_request
diff --git a/newspipe/web/views/user.py b/newspipe/web/views/user.py
index f4f26b71..23a662ac 100644
--- a/newspipe/web/views/user.py
+++ b/newspipe/web/views/user.py
@@ -201,7 +201,7 @@ def delete_account():
"""
UserController(current_user.id).delete(current_user.id)
flash(gettext("Your account has been deleted."), "success")
- return redirect(url_for("login"))
+ return redirect(url_for("logout"))
@user_bp.route("/confirm_account/<string:token>", methods=["GET"])
bgstack15