metasrht-manageuser: skip username blacklist
This commit is contained in:
parent
7e45ec86a3
commit
b3e31d9997
|
@ -41,6 +41,15 @@ network-key=
|
|||
# ill effect, if this better suits your infrastructure.
|
||||
redis-host=
|
||||
|
||||
[objects]
|
||||
#
|
||||
# Configure S3-compatible object storage for services. Optional.
|
||||
#
|
||||
# Minio is recommended as a FOSS solution over AWS: https://min.io
|
||||
s3-upstream=
|
||||
s3-access-key=
|
||||
s3-secret-key=
|
||||
|
||||
[mail]
|
||||
#
|
||||
# Outgoing SMTP settings
|
||||
|
|
|
@ -102,7 +102,7 @@ def error_on_invalid(valid):
|
|||
|
||||
def validate_user(username, email):
|
||||
valid = Validation({})
|
||||
auth_validation.validate_username(valid, username)
|
||||
auth_validation.validate_username(valid, username, check_blacklist=False)
|
||||
auth_validation.validate_email(valid, email)
|
||||
error_on_invalid(valid)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from srht.config import cfg
|
|||
from zxcvbn import zxcvbn
|
||||
|
||||
|
||||
def validate_username(valid, username):
|
||||
def validate_username(valid, username, check_blacklist=True):
|
||||
user = User.query.filter(User.username == username).first()
|
||||
valid.expect(user is None, "This username is already in use.", "username")
|
||||
valid.expect(2 <= len(username) <= 30,
|
||||
|
@ -18,7 +18,7 @@ def validate_username(valid, username):
|
|||
valid.expect(re.match("^[a-z0-9_-]+$", username),
|
||||
"Username may contain only lowercase letters, numbers, "
|
||||
"hyphens and underscores", "username")
|
||||
valid.expect(username not in username_blacklist,
|
||||
valid.expect(not check_blacklist or username not in username_blacklist,
|
||||
"This username is not available", "username")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue