From 9e6822bcdb178ae7c3d0aad3a8aa9b85b19c4454 Mon Sep 17 00:00:00 2001 From: Ymage Date: Sat, 24 Nov 2018 11:53:27 +0100 Subject: [PATCH 1/2] Make a redirection to previous page after logged in Fix #403 --- app/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/views.py b/app/views.py index ff9cb9d..68afbed 100644 --- a/app/views.py +++ b/app/views.py @@ -301,6 +301,12 @@ def saml_authorized(): @app.route('/login', methods=['GET', 'POST']) @login_manager.unauthorized_handler +def unauthorized_callback(): + session['next'] = request.path + return redirect('/login') + + +@app.route('/login', methods=['GET', 'POST']) def login(): SAML_ENABLED = app.config.get('SAML_ENABLED') @@ -425,7 +431,7 @@ def login(): return render_template('login.html', saml_enabled=SAML_ENABLED, error='Token required') login_user(user, remember = remember_me) - return redirect(request.args.get('next') or url_for('index')) + return redirect(session.get('next', url_for('index'))) else: if not username or not password or not email: return render_template('register.html', error='Please input required information') From 0b9c58971c6be7b83dbf9a05c5db1161b9baebb2 Mon Sep 17 00:00:00 2001 From: Ymage Date: Sat, 24 Nov 2018 12:15:49 +0100 Subject: [PATCH 2/2] Remove forgotten decorator --- app/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views.py b/app/views.py index 68afbed..0dfb103 100644 --- a/app/views.py +++ b/app/views.py @@ -299,7 +299,6 @@ def saml_authorized(): return render_template('errors/SAML.html', errors=errors) -@app.route('/login', methods=['GET', 'POST']) @login_manager.unauthorized_handler def unauthorized_callback(): session['next'] = request.path