Wrong password feedback and no need to expose password requirements at login

This commit is contained in:
crunk 2022-01-23 12:08:47 +01:00
parent 6486d4b0a0
commit b4b9b7ed58
2 changed files with 3 additions and 1 deletions

View File

@ -18,6 +18,6 @@ class LoginForm(FlaskForm):
validators=[validators.InputRequired(), Email(), Length(6, 64)], validators=[validators.InputRequired(), Email(), Length(6, 64)],
) )
password = PasswordField( password = PasswordField(
"Password:", validators=[validators.InputRequired(), Length(12, 72)] "Password:", validators=[validators.InputRequired()]
) )
submit = SubmitField("Sign In") submit = SubmitField("Sign In")

View File

@ -81,6 +81,8 @@ def login():
return redirect(next or url_for("index")) return redirect(next or url_for("index"))
else: else:
flash("Invalid Username or password!", "danger") flash("Invalid Username or password!", "danger")
loginform.password.errors.append("Invalid email or password!")
return render_template("login.html", loginform=loginform)
except Exception as e: except Exception as e:
flash(e, "danger") flash(e, "danger")
return render_template("login.html", loginform=loginform) return render_template("login.html", loginform=loginform)