From 7d77a8bf5df8f641807f76cad3cac614ed2f9cf9 Mon Sep 17 00:00:00 2001 From: Stefano Date: Wed, 13 Sep 2017 09:17:23 +0200 Subject: [PATCH] Add logout page (Why was it missing in the first place?) --- server.py | 12 ++++++++++-- templates/nav.htm | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index b9234be..7c6c09d 100644 --- a/server.py +++ b/server.py @@ -190,8 +190,7 @@ def page_home(): if 'username' not in session: return redirect(url_for('page_login')) else: - session.pop('username') - return redirect(url_for('page_login')) + return redirect(url_for('page_dashboard')) @app.route('/login', methods=['GET', 'POST']) @@ -210,6 +209,15 @@ def page_login(): return render_template('error.htm', error="Username o password non validi.") +@app.route('/logout') +def page_logout(): + """Pagina di logout: + slogga l'utente se visitata""" + if 'username' in session: + session.pop('username') + return redirect(url_for('page_login')) + + @app.route('/dashboard') def page_dashboard(): """Dashboard del sito: diff --git a/templates/nav.htm b/templates/nav.htm index d1c0666..79d1396 100644 --- a/templates/nav.htm +++ b/templates/nav.htm @@ -20,7 +20,7 @@ - Logout + Logout {% endif %}