Make a redirection to previous page after logged in

Fix #403
This commit is contained in:
Ymage 2018-11-24 11:53:27 +01:00
parent 2f39512b65
commit 9e6822bcdb

View File

@ -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')