diff --git a/app/templates/auth/change_password.html b/app/templates/auth/change_password.html
index 702059c8..975e8bc9 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 e1709c92..7a03a899 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))