From 782da97a1f0337e8dd6155f49b7e49f69a31c74d Mon Sep 17 00:00:00 2001 From: augustin64 Date: Sat, 24 Jun 2023 15:37:43 +0200 Subject: [PATCH] Add h2 to login/ register --- partitioncloud/modules/auth.py | 10 +++++----- partitioncloud/templates/auth/login.html | 3 ++- partitioncloud/templates/auth/register.html | 3 ++- partitioncloud/templates/partition/delete.html | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/partitioncloud/modules/auth.py b/partitioncloud/modules/auth.py index 8f52370..210f4f3 100644 --- a/partitioncloud/modules/auth.py +++ b/partitioncloud/modules/auth.py @@ -94,15 +94,17 @@ def register(): (username, generate_password_hash(password)), ) db.commit() + flash(f"Utilisateur {username} créé avec succès. Vous pouvez vous connecter.") except db.IntegrityError: # The username was already taken, which caused the # 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: # Success, go to the login page. return redirect(url_for("auth.login")) flash(error) + db.close() return render_template("auth/register.html") @@ -119,10 +121,8 @@ def login(): "SELECT * FROM user WHERE username = ?", (username,) ).fetchone() - if user is None: - error = "Incorrect username." - elif not check_password_hash(user["password"], password): - error = "Incorrect password." + if (user is None) or not check_password_hash(user["password"], password): + error = "Nom d'utilisateur ou mot de passe incorrect." if error is None: # store the user id in a new session and return to the index diff --git a/partitioncloud/templates/auth/login.html b/partitioncloud/templates/auth/login.html index 7625da2..9051e1d 100644 --- a/partitioncloud/templates/auth/login.html +++ b/partitioncloud/templates/auth/login.html @@ -1,8 +1,9 @@ {% extends 'base.html' %} -{% block title %}Connexion{% endblock %} {% block content %} +

{% block title %}Connexion{% endblock %}

+


diff --git a/partitioncloud/templates/auth/register.html b/partitioncloud/templates/auth/register.html index 232f6fe..779c4d6 100644 --- a/partitioncloud/templates/auth/register.html +++ b/partitioncloud/templates/auth/register.html @@ -1,8 +1,9 @@ {% extends 'base.html' %} -{% block title %}Créer un compte{% endblock %} {% block content %} +

{% block title %}Créer un compte{% endblock %}

+ {% if g.user.access_level == 1 %} diff --git a/partitioncloud/templates/partition/delete.html b/partitioncloud/templates/partition/delete.html index 45ec4e1..7d1ef20 100644 --- a/partitioncloud/templates/partition/delete.html +++ b/partitioncloud/templates/partition/delete.html @@ -7,7 +7,7 @@ {% block content %} Êtes vous sûr de vouloir supprimer cette partition ? - +