From e9b1e7a7346b39d500e71504f9dde798c49a9216 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 19 Apr 2014 16:46:40 +0200 Subject: Updated error messages for authentication --- pyaggr3g470r/views.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index c1fa459e..21ca153c 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -79,16 +79,6 @@ def before_request(): #db.session.add(g.user) #db.session.commit() -@app.errorhandler(403) -def authentication_failed(e): - flash('Authentication failed.', 'danger') - return redirect(url_for('login')) - -@app.errorhandler(401) -def authentication_failed(e): - flash('Authentication required.', 'info') - return redirect(url_for('login')) - @login_manager.user_loader def load_user(email): # Return an instance of the User model @@ -98,6 +88,16 @@ def load_user(email): # # Custom error pages. # +@app.errorhandler(401) +def authentication_failed(e): + flash('Authentication required.', 'info') + return redirect(url_for('login')), 401 + +@app.errorhandler(403) +def authentication_failed(e): + flash('Authentication failed.', 'danger') + return redirect(url_for('login')), 403 + @app.errorhandler(404) def page_not_found(e): return render_template('errors/404.html'), 404 -- cgit