1
Fork 0
mirror of https://github.com/Steffo99/estus.git synced 2024-11-22 07:34:19 +00:00

Add logout page

(Why was it missing in the first place?)
This commit is contained in:
Steffo 2017-09-13 09:17:23 +02:00
parent ec98062e0e
commit 7d77a8bf5d
2 changed files with 11 additions and 3 deletions

View file

@ -190,8 +190,7 @@ def page_home():
if 'username' not in session: if 'username' not in session:
return redirect(url_for('page_login')) return redirect(url_for('page_login'))
else: else:
session.pop('username') return redirect(url_for('page_dashboard'))
return redirect(url_for('page_login'))
@app.route('/login', methods=['GET', 'POST']) @app.route('/login', methods=['GET', 'POST'])
@ -210,6 +209,15 @@ def page_login():
return render_template('error.htm', error="Username o password non validi.") 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') @app.route('/dashboard')
def page_dashboard(): def page_dashboard():
"""Dashboard del sito: """Dashboard del sito:

View file

@ -20,7 +20,7 @@
<li class="navbar-text"> <li class="navbar-text">
Sei connesso come <b>{{user}}</b> Sei connesso come <b>{{user}}</b>
</li> </li>
<a href="/login" class="btn btn-danger navbar-btn btn-right">Logout</a> <a href="/logout" class="btn btn-danger navbar-btn btn-right">Logout</a>
</ul> </ul>
{% endif %} {% endif %}
</div> </div>