From 063b7dffebfaaa99bca9bc1ec9e3293cb33188b4 Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Fri, 4 Jun 2021 00:44:20 +0530 Subject: addde message template and 401 handler --- app/templates/message.html | 17 +++++++++++++++++ app/views/auth.py | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/templates/message.html diff --git a/app/templates/message.html b/app/templates/message.html new file mode 100644 index 0000000..24603ef --- /dev/null +++ b/app/templates/message.html @@ -0,0 +1,17 @@ +{% extends "base.html" %} +{% block title %}Message{% endblock %} +{% block head %} + {{ super() }} +{% endblock %} +{% block content %} +
+
+ {% if code is defined %} +

{{code}}

+ {% endif %} +

{{ message }}

+ +

Click here to go home.

+
+
+{% endblock %} \ No newline at end of file diff --git a/app/views/auth.py b/app/views/auth.py index a915cf4..1d1cafb 100644 --- a/app/views/auth.py +++ b/app/views/auth.py @@ -42,12 +42,16 @@ def signin_user(): flash_errors(form) return render_template("auth/signin.html",form=form) -@flask_login.login_required @app.route("/dashboard") +@flask_login.login_required def user_dashboard(): return render_template("dashboard.html",user=flask_login.current_user) @app.route('/logout') def logout(): flask_login.logout_user() - return 'Logged out' + return render_template("message.html",message="You have been logged out.") + +@login_manager.unauthorized_handler +def unauthorized(): + return render_template("message.html",message="You need to be logged in to access this resource", code=401) -- cgit v1.2.3