Merge pull request #406 from ymage/fix-403

Make a redirection to previous page after logged in
This commit is contained in:
Khanh Ngo 2018-11-26 10:35:43 +07:00 committed by GitHub
commit 32c442e083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -299,8 +299,13 @@ 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
return redirect('/login')
@app.route('/login', methods=['GET', 'POST'])
def login():
SAML_ENABLED = app.config.get('SAML_ENABLED')
@ -425,7 +430,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')