index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | SecondThundeR <awayfromgalaxy@gmail.com> | 2021-04-05 19:22:48 +0300 |
---|---|---|
committer | SecondThundeR <awayfromgalaxy@gmail.com> | 2021-04-05 19:22:48 +0300 |
commit | ed2187ee709e40e9da50cec9f0eaf45e77d6a8e9 (patch) | |
tree | cce1007432fe60af3d64eb0fd6dc90d2d6cd7501 /archinstall/lib | |
parent | 5de1154ce9708f770bacae5faa2ef3c3eea4c2e2 (diff) |
-rw-r--r-- | archinstall/lib/user_interaction.py | 24 |
diff --git a/archinstall/lib/user_interaction.py b/archinstall/lib/user_interaction.py index 30008fad..a337066e 100644 --- a/archinstall/lib/user_interaction.py +++ b/archinstall/lib/user_interaction.py @@ -18,6 +18,16 @@ def get_terminal_width(): def get_longest_option(options): return max([len(x) for x in options]) +def check_for_correct_username(username): + if re.match(r'^[a-z_][a-z0-9_-]*\$?$', username) and len(username) <= 32: + return True + log( + "The username you entered is invalid. Try again", + level=LOG_LEVELS.Warning, + fg='red' + ) + return False + def get_password(prompt="Enter a password: "): while (passwd := getpass.getpass(prompt)): passwd_verification = getpass.getpass(prompt='And one more time for verification: ') @@ -51,12 +61,7 @@ def ask_for_superuser_account(prompt='Create a required super-user with sudo pri while 1: new_user = input(prompt).strip(' ') - if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32: - log( - "The username you entered is invalid. Try again", - level=LOG_LEVELS.Warning, - fg='red' - ) + if not check_for_correct_username(new_user): continue if not new_user and forced: # TODO: make this text more generic? @@ -77,12 +82,7 @@ def ask_for_additional_users(prompt='Any additional users to install (leave blan new_user = input(prompt).strip(' ') if not new_user: break - if not re.match('[a-z_][a-z0-9_-]*[$]?', new_user) or len(new_user) > 32: - log( - "The username you entered is invalid. Try again", - level=LOG_LEVELS.Warning, - fg='red' - ) + if not check_for_correct_username(new_user): continue password = get_password(prompt=f'Password for user {new_user}: ') |