Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall
diff options
context:
space:
mode:
Diffstat (limited to 'archinstall')
-rw-r--r--archinstall/lib/user_interaction.py24
1 files changed, 12 insertions, 12 deletions
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}: ')