Allow uppercase Chars afters first character in usernames

pull/4/head
Darksider3 5 years ago
parent 91b5e6ae7b
commit 5a57a62780

@ -5,10 +5,10 @@ import lib.CFG as CFG
def checkUsernameCharacters(username: str): def checkUsernameCharacters(username: str):
if " " not in username and "_" not in username and username.isascii() and username.islower() and \ if " " not in username and "_" not in username and username.isascii() and username[:1].islower() and \
not username[0].isnumeric(): not username[0].isnumeric():
if not re.search(r"\W+", username): if not re.search(r"\W+", username):
if not re.search("[^a-z0-9]", username): if not re.search("[^a-zA-Z0-9]", username):
return True return True
return False return False
@ -88,24 +88,27 @@ def checkImportFile(f):
for row in reador: for row in reador:
# if any of this fails move on to the next user, just print a relatively helpful message lel # if any of this fails move on to the next user, just print a relatively helpful message lel
if not lib.validator.checkUsernameCharacters(row["username"]): if not lib.validator.checkUsernameCharacters(row["username"]):
error_list += (f"Line {ln}: The username contains unsupported characters or starts with a number: '" error_list += (f"Line {ln}: Username contains unsupported characters or starts with a number: '"
f"{row['username']}'.\n") f"{row['username']}'.\n")
valid = False valid = False
if not lib.validator.checkUsernameLength(row["username"]): if not lib.validator.checkUsernameLength(row["username"]):
error_list += f"Line {ln}: The username '{row['username']}' is either too long(>16) or short(<3)\n" error_list += f"Line {ln}: Username '{row['username']}' is either too long(>16) or short(<3)\n"
valid = False valid = False
if not lib.validator.checkSSHKey(row["pubkey"]): if not lib.validator.checkSSHKey(row["pubkey"]):
error_list += f"Line {ln}: Following SSH-Key from user '{row['username']}' isn't valid: '{row['pubkey']}'."\ error_list += f"Line {ln}: Following SSH-Key of user '{row['username']}' isn't valid: '{row['pubkey']}'."\
f"\n" f"\n"
valid = False valid = False
if not lib.validator.checkEmail(row["email"]): if not lib.validator.checkEmail(row["email"]):
error_list += f"Line {ln}: The E-Mail address of user '{row['username']}' '{row['email']}' is not valid.\n" error_list += f"Line {ln}: E-Mail address of user '{row['username']}' '{row['email']}' is not valid.\n"
valid = False valid = False
if not lib.validator.checkUserExists(row["username"]): if not lib.validator.checkUserExists(row["username"]):
error_list += f"Line {ln}: The user '{row['username']}' already exists.\n" error_list += f"Line {ln}: User '{row['username']}' already exists.\n"
valid = False valid = False
if not lib.validator.checkDatetimeFormat(row["timestamp"]): if not lib.validator.checkDatetimeFormat(row["timestamp"]):
error_list += f"Line {ln}: The timestamp '{row['timestamp']}' from user '{row['username']}' is invalid.\n" error_list += f"Line {ln}: Timestamp '{row['timestamp']}' from user '{row['username']}' is invalid.\n"
valid = False
if int(row["status"]) > 1 or int(row["status"]) < 0:
error_list += f"Line {ln}: Status '{row['status']}' MUST be either 0 or 1.\n"
valid = False valid = False
ln += 1 ln += 1
if valid: if valid:

@ -77,7 +77,7 @@ def __checkSQLite(cursor, connection):
def check_username(value): def check_username(value):
global VALID_USER global VALID_USER
if " " in value or "_ " in value or not value.isascii() or not value.islower() or value[0].isnumeric(): if " " in value or "_ " in value or not value.isascii() or not value[:1].islower() or value[0].isnumeric():
VALID_USER = False VALID_USER = False
return False return False
if re.search(r"\W+", value): if re.search(r"\W+", value):

Loading…
Cancel
Save