Added redirect on 401 Unauthorized

This commit is contained in:
Robbe Van Herck 2018-11-29 16:14:20 +01:00
parent f2e0be83b9
commit 6fa0ea598c
No known key found for this signature in database
GPG key ID: 4D1C8E8FBD1C7188

View file

@ -13,6 +13,10 @@ def load_user(userid):
return User.query.filter_by(id=userid).first() return User.query.filter_by(id=userid).first()
@app.errorhandler(401)
def custom_401(_):
return redirect(url_for('login'))
@app.route('/login') @app.route('/login')
def login(): def login():
return zeus_login() return zeus_login()
@ -23,4 +27,4 @@ def logout():
if 'zeus_token' in session: if 'zeus_token' in session:
session.pop('zeus_token', None) session.pop('zeus_token', None)
logout_user() logout_user()
return redirect(url_for('all_users')) return redirect(url_for('all_users'))