mirror of
https://github.com/partitioncloud/partitioncloud-server.git
synced 2025-04-22 05:33:55 +02:00
Add h2 to login/ register
This commit is contained in:
parent
1cb8d45960
commit
782da97a1f
@ -94,15 +94,17 @@ def register():
|
|||||||
(username, generate_password_hash(password)),
|
(username, generate_password_hash(password)),
|
||||||
)
|
)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
flash(f"Utilisateur {username} créé avec succès. Vous pouvez vous connecter.")
|
||||||
except db.IntegrityError:
|
except db.IntegrityError:
|
||||||
# The username was already taken, which caused the
|
# The username was already taken, which caused the
|
||||||
# commit to fail. Show a validation error.
|
# commit to fail. Show a validation error.
|
||||||
error = f"Le nom d'utilisateur {username} est déjà pris."
|
error = f"Le nom d'utilisateur {username} est déjà pris. Vous souhaitez peut-être vous connecter"
|
||||||
else:
|
else:
|
||||||
# Success, go to the login page.
|
# Success, go to the login page.
|
||||||
return redirect(url_for("auth.login"))
|
return redirect(url_for("auth.login"))
|
||||||
|
|
||||||
flash(error)
|
flash(error)
|
||||||
|
db.close()
|
||||||
|
|
||||||
return render_template("auth/register.html")
|
return render_template("auth/register.html")
|
||||||
|
|
||||||
@ -119,10 +121,8 @@ def login():
|
|||||||
"SELECT * FROM user WHERE username = ?", (username,)
|
"SELECT * FROM user WHERE username = ?", (username,)
|
||||||
).fetchone()
|
).fetchone()
|
||||||
|
|
||||||
if user is None:
|
if (user is None) or not check_password_hash(user["password"], password):
|
||||||
error = "Incorrect username."
|
error = "Nom d'utilisateur ou mot de passe incorrect."
|
||||||
elif not check_password_hash(user["password"], password):
|
|
||||||
error = "Incorrect password."
|
|
||||||
|
|
||||||
if error is None:
|
if error is None:
|
||||||
# store the user id in a new session and return to the index
|
# store the user id in a new session and return to the index
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block title %}Connexion{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<h2>{% block title %}Connexion{% endblock %}</h2>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="text" name="username" id="username" placeholder="Nom d'utilisateur" required><br/>
|
<input type="text" name="username" id="username" placeholder="Nom d'utilisateur" required><br/>
|
||||||
<input type="password" name="password" id="password" placeholder="Mot de passe" required><br/>
|
<input type="password" name="password" id="password" placeholder="Mot de passe" required><br/>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block title %}Créer un compte{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<h2>{% block title %}Créer un compte{% endblock %}</h2>
|
||||||
|
|
||||||
<form method="post" id="add-user-form">
|
<form method="post" id="add-user-form">
|
||||||
{% if g.user.access_level == 1 %}
|
{% if g.user.access_level == 1 %}
|
||||||
<!-- Uniquement pour /add-user -->
|
<!-- Uniquement pour /add-user -->
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
Êtes vous sûr de vouloir supprimer cette partition ?
|
Êtes vous sûr de vouloir supprimer cette partition ?
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="submit" value="Supprimer">
|
<input type="submit" id="delete-partition" value="Supprimer">
|
||||||
</form>
|
</form>
|
||||||
<a class="button-href" href="/albums/{{ partition.uuid }}/edit">
|
<a class="button-href" href="/albums/{{ partition.uuid }}/edit">
|
||||||
<button id="cancel-deletion">Annuler</button>
|
<button id="cancel-deletion">Annuler</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user