Require email in set password

This commit is contained in:
rubenwardy 2018-06-04 18:34:04 +01:00
parent aad4fd2a70
commit 4420f489ac
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C

@ -109,7 +109,7 @@ def user_profile_page(username):
user=user, form=form, packages=packages, topics_to_add=topics_to_add)
class SetPasswordForm(FlaskForm):
email = StringField("Email (Optional)", [Optional(), Email()])
email = StringField("Email", [Optional(), Email()])
password = PasswordField("New password", [InputRequired(), Length(2, 20)])
password2 = PasswordField("Verify password", [InputRequired(), Length(2, 20)])
submit = SubmitField("Save")
@ -121,6 +121,9 @@ def set_password_page():
return redirect(url_for("user.change_password"))
form = SetPasswordForm(request.form)
if current_user.email == None:
form.email.validators = [InputRequired(), Email()]
if request.method == "POST" and form.validate():
one = form.password.data
two = form.password2.data