Forbid guids as usernames

This commit is contained in:
Tim Van Baak 2020-01-29 01:03:20 -08:00
parent 1068dacade
commit 1b1332a42d
1 changed files with 8 additions and 1 deletions

View File

@ -73,7 +73,14 @@ class UserModel(UserMixin):
def valid_username(username):
return re.match(r"^[A-Za-z0-9-_]{3,}$", username) is not None
"""
A valid username is at least three characters long and composed solely of
alpahnumerics, dashes, and underscores. Additionally, usernames may not
be 32 hex digits, since that may be confused for an internal id.
"""
length_and_characters = re.match(r"^[A-Za-z0-9-_]{3,}$", username)
is_a_guid = re.match(r"^[A-Za-z0-9]{32}$", username)
return length_and_characters and not is_a_guid
def valid_email(email):
"""Vaguely RFC2822 email verifier"""