feat(password): added a password reset page (and unused form), corrected the validation of the password changer, modified styles
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-12-06 17:47:05 +01:00
parent d5a8445df3
commit bcf50ff111
7 changed files with 118 additions and 48 deletions

View File

@@ -7,11 +7,11 @@ from flask import (
from flask_wtf import FlaskForm
from wtforms import (
StringField, PasswordField,
SubmitField
SubmitField, EmailField
)
from wtforms.validators import (
ValidationError, DataRequired,
EqualTo, Length, Regexp
EqualTo, Length, Regexp, Email
)
bp = Blueprint('password', __name__, url_prefix='/password')
@@ -37,14 +37,15 @@ class ChangePasswordForm(FlaskForm):
# "(?=.*[@$!%*#?&])", message="Password must contain a special character"
#),],
],
render_kw={"onkeyup": f"validate_form({minlength})"})
render_kw={"onkeyup": f"validate_username_form({minlength})"})
confirm_password = PasswordField(
label=('Confirm Password'),
validators=[DataRequired(message='* Required'),
EqualTo('newpassword')],
render_kw={"onkeyup": f"validate_confirm({minlength})"})
render_kw={"onkeyup": f"validate_username_form({minlength})"})
submit = SubmitField(label=('Change my password'), render_kw={"onclick": f"validate_form({minlength})"})
submit = SubmitField(label=('Change my password'), render_kw={"disabled": "true",
"onclick": f"validate_username_form({minlength})"})
# Validators
def validate_username(self, username):
@@ -54,7 +55,15 @@ class ChangePasswordForm(FlaskForm):
raise ValidationError(
f"Character {char} is not allowed in an username.")
@bp.route('/change', methods=('GET', 'POST'))
class ResetPasswordForm(FlaskForm):
email = EmailField(label=('Email address'),
validators=[DataRequired(), Email()],
render_kw={"onkeyup": f"validate_email()"})
submit = SubmitField(label=('Change my password'), render_kw={"disabled": "true",
"onclick": f"validate_email()"})
@bp.route('/change', methods=["GET", "POST"])
def change():
form = ChangePasswordForm()
if form.validate_on_submit():
@@ -71,3 +80,7 @@ def change():
client.unbind()
return render_template('change.html', form=form)
@bp.route('/reset', methods=["GET"])
def reset():
return render_template('reset.html')