mirror of
https://github.com/Steffo99/estus.git
synced 2024-11-21 23:24:18 +00:00
Add logout page
(Why was it missing in the first place?)
This commit is contained in:
parent
ec98062e0e
commit
7d77a8bf5d
2 changed files with 11 additions and 3 deletions
12
server.py
12
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:
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<li class="navbar-text">
|
||||
Sei connesso come <b>{{user}}</b>
|
||||
</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>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue