mirror of
https://github.com/hrfee/jellyfin-accounts.git
synced 2025-12-08 11:39:33 +00:00
Fixed password validation on form; added lowercase option
Fixed an issue where some criteria on the form page wouldn't change to red or green when one set one of them to 0 in the config. Also added a lowercase option.
This commit is contained in:
@@ -2,20 +2,24 @@ specials = ['[', '@', '_', '!', '#', '$', '%', '^', '&', '*', '(', ')',
|
||||
'<', '>', '?', '/', '\\', '|', '}', '{', '~', ':', ']']
|
||||
|
||||
class PasswordValidator:
|
||||
def __init__(self, min_length, upper, number, special):
|
||||
def __init__(self, min_length, upper, lower, number, special):
|
||||
self.criteria = {'characters': int(min_length),
|
||||
'uppercase characters': int(upper),
|
||||
'lowercase characters': int(lower),
|
||||
'numbers': int(number),
|
||||
'special characters': int(special)}
|
||||
def validate(self, password):
|
||||
count = {'characters': 0,
|
||||
'uppercase characters': 0,
|
||||
'lowercase characters': 0,
|
||||
'numbers': 0,
|
||||
'special characters': 0}
|
||||
for c in password:
|
||||
count['characters'] += 1
|
||||
if c.isupper():
|
||||
count['uppercase characters'] += 1
|
||||
elif c.islower():
|
||||
count['lowercase characters'] += 1
|
||||
elif c.isnumeric():
|
||||
count['numbers'] += 1
|
||||
elif c in specials:
|
||||
|
||||
@@ -69,10 +69,11 @@ while attempts != 3:
|
||||
if config.getboolean('password_validation', 'enabled'):
|
||||
validator = PasswordValidator(config['password_validation']['min_length'],
|
||||
config['password_validation']['upper'],
|
||||
config['password_validation']['lower'],
|
||||
config['password_validation']['number'],
|
||||
config['password_validation']['special'])
|
||||
else:
|
||||
validator = PasswordValidator(0, 0, 0, 0)
|
||||
validator = PasswordValidator(0, 0, 0, 0, 0)
|
||||
|
||||
|
||||
@app.route('/getRequirements', methods=['GET', 'POST'])
|
||||
|
||||
Reference in New Issue
Block a user