diff options
| author | 2026-08-12 21:59:54 +0200 | |
|---|---|---|
| committer | 2026-08-12 21:59:54 +0200 | |
| commit | 039a1424ef228b062c018bff1bc132800c8c2cfb (patch) | |
| tree | 031ed5e29b13884dd783dbdc6d5e0a3a86401a24 /src/init | |
| parent | df5b3c3496b459737e98c7061f30324872ae9b00 (diff) | |
Moved user check into function and also verify in repo setup proper username
Diffstat (limited to 'src/init')
| -rwxr-xr-x | src/init | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -28,10 +28,7 @@ function setupUser set -l key $userConfig[2] # validate username - if not string match -q -r -- $_USER_VALIDATION_REGEX "$user" - echo "Error: User '$user' does not match validation regex" - return 1 - end + checkUsername "$user"; or return $status echo "Setting up user: $user" if [ "$user" = git ] @@ -59,6 +56,17 @@ function setupUser chmod -R 700 "$HOME" end +function checkUsername + set -l user "$argv[1]" + # validate username + if not string match -q -r -- "^$_USER_VALIDATION_REGEX\$" "$user" + echo "Error: User '$user' does not match validation regex" + return 1 + end + + return 0 +end + function setupGitUser doesUserExist "git"; and return 0 echo "Setting up git user" @@ -92,7 +100,11 @@ function setupRepo set -l parsedConfig (string split ':' -- $userConfig) set -l user $parsedConfig[1] set -l permission $parsedConfig[2] - + + if not checkUsername "$user" + continue + end + # check for valid permission if not contains $permission $_PERMISSIONS set permission "r" |
