From 264c0d7d9ee4580f2cae5d415a013df9a9f21bca Mon Sep 17 00:00:00 2001 From: Place Jean-Marie Date: Sun, 17 Oct 2021 12:15:24 +0200 Subject: [PATCH] =?UTF-8?q?traduction/adaptation=20messages=20par=20d?= =?UTF-8?q?=C3=A9faut=20;=20strip=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/auth/change_password.html | 10 ---------- app/views/users.py | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/templates/auth/change_password.html b/app/templates/auth/change_password.html index 702059c8c..975e8bc97 100644 --- a/app/templates/auth/change_password.html +++ b/app/templates/auth/change_password.html @@ -39,14 +39,4 @@ #} -{#
Votre identifiant: {{user.user_name}}
#} -{##} -{##} -{#
#} -{#
#} -{# {{ wtf.quick_form(form) }}#} -{#
#} -{#
#} {% endblock %} \ No newline at end of file diff --git a/app/views/users.py b/app/views/users.py index e1709c92a..7a03a899c 100644 --- a/app/views/users.py +++ b/app/views/users.py @@ -79,7 +79,7 @@ _l = _ class ChangePasswordForm(FlaskForm): user_name = HiddenField() - old_password = PasswordField(_l("Ancien mot de passe")) + old_password = PasswordField(_l("Identifiez-vous")) new_password = PasswordField(_l("Nouveau mot de passe")) bis_password = PasswordField( _l("Répéter"), @@ -90,14 +90,22 @@ class ChangePasswordForm(FlaskForm): ), ], ) - email = StringField(_l("Email"), validators=[DataRequired(), Email()]) + email = StringField( + _l("Email"), + validators=[ + DataRequired(), + Email(message="adresse email invalide, recommencez"), + ], + ) submit = SubmitField() cancel = SubmitField("Annuler") def validate_email(self, email): - user = User.query.filter_by(email=email.data).first() + user = User.query.filter_by(email=email.data.strip()).first() if user is not None and self.user_name.data != user.user_name: - raise ValidationError(_("Adresse e-mail invalide")) + raise ValidationError( + _("Cette adresse e-mail est déjà attribuée à un autre compte") + ) def validate_new_password(self, new_password): if new_password.data != "" and not is_valid_password(new_password.data): @@ -771,8 +779,8 @@ def form_change_password(user_name=None): if form.new_password.data != "": # change password user.set_password(form.new_password.data) messages.append("Mot de passe modifié") - if form.email.data != user.email: # change email - user.email = form.email.data + if form.email.data.strip() != user.email: # change email + user.email = form.email.data.strip() messages.append("Adresse email modifiée") db.session.commit() flash("\n".join(messages))