Bugfixes for password policy

This commit is contained in:
Ozzie Isaacs
2023-02-15 19:53:35 +01:00
parent 66d5b5a697
commit 8ee34bf428
5 changed files with 19 additions and 9 deletions
+3 -3
View File
@@ -612,7 +612,7 @@ def reset_password(user_id):
if not config.get_mail_server_configured():
return 2, None
try:
password = generate_random_password()
password = generate_random_password(config.config_password_min_length)
existing_user.password = generate_password_hash(password)
ub.session.commit()
send_registration_mail(existing_user.email, existing_user.name, password, True)
@@ -622,9 +622,9 @@ def reset_password(user_id):
return 0, None
def generate_random_password():
def generate_random_password(min_length):
s = "abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%&*()?"
passlen = 8
passlen = min_length
return "".join(s[c % len(s)] for c in os.urandom(passlen))