feat(reset): added a name validator

This commit is contained in:
2021-11-29 02:00:06 +01:00
parent 442f920681
commit 45295860c3
4 changed files with 32 additions and 11 deletions

View File

@@ -20,15 +20,16 @@ class ResetPasswordForm(FlaskForm):
# Form
username = StringField(label=('Login'),
validators=[DataRequired(),
Length(max=64)])
Length(max=64)],
render_kw={"onkeyup": "validate_username()"})
currentpassword = PasswordField(label=('Current password'),
validators=[DataRequired()])
newpassword = PasswordField(label=('New password'),
validators=[DataRequired(),
Length(min=minlength, message='Password should be at least %(min)d characters long'),
Regexp("^(?=.*[a-z])", message="Password must have a lowercase character"),
Regexp("^(?=.*[A-Z])", message="Password must have an uppercase character"),
Regexp("^(?=.*\\d)", message="Password must contain a number"),
Length(min=minlength),
Regexp("^(?=.*[a-z])"),
Regexp("^(?=.*[A-Z])"),
Regexp("^(?=.*\\d)"),
#Regexp(
# "(?=.*[@$!%*#?&])", message="Password must contain a special character"
#),],
@@ -37,7 +38,7 @@ class ResetPasswordForm(FlaskForm):
confirm_password = PasswordField(
label=('Confirm Password'),
validators=[DataRequired(message='* Required'),
EqualTo('newpassword', message='Both password fields must be equal!')],
EqualTo('newpassword')],
render_kw={"onkeyup": f"validate_confirm({minlength})"})
submit = SubmitField(label=('Change my password'), render_kw={"onclick": f"validate_form({minlength})"})