mirror of
https://github.com/Steffo99/estus.git
synced 2024-11-25 00:54:18 +00:00
Stop the deletion of the user you're currently logged in with.
This commit is contained in:
parent
83651adda1
commit
9ca51a03ad
2 changed files with 3 additions and 1 deletions
|
@ -641,6 +641,8 @@ def page_user_del(uid):
|
|||
if User.query.count() <= 1:
|
||||
return render_template("error.htm", error="Non puoi cancellare l'ultimo utente rimasto!")
|
||||
utente = User.query.get_or_404(uid)
|
||||
if utente.username == session["username"]:
|
||||
return render_template("error.htm", error="Non puoi cancellare l'utente con cui sei loggato!")
|
||||
db.session.delete(utente)
|
||||
db.session.commit()
|
||||
return redirect(url_for('page_user_list'))
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<tr>
|
||||
{% for utente in utenti %}
|
||||
<td>{{ utente.username }}</td>
|
||||
<td>{% if utenti|length >= 2 %}<a href="/user_del/{{ utente.uid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
|
||||
<td>{% if utenti|length >= 2 and utente.username != user %}<a href="/user_del/{{ utente.uid }}"><span class="glyphicon glyphicon-remove"></span></a>{% endif %}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue