This commit is contained in:
Florent Daigniere
2022-11-03 16:19:44 +01:00
parent 5d314c49ae
commit 66250e396c
3 changed files with 23 additions and 34 deletions

View File

@@ -507,3 +507,14 @@ def gen_temp_token(email, session):
app.config['PERMANENT_SESSION_LIFETIME'],
)
return token
def isBadOrPwned(form):
try:
if len(form.pw.data) < 8:
return "This password is too short."
breaches = int(form.pwned.data)
except ValueError:
breaches = -1
if breaches > 0:
return f"This password appears in {breaches} data breaches! It is not unique; please change it."
return None