From 30526a4caac496bdcf82dff5706de374dd80891d Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Mon, 22 Nov 2021 21:01:43 +0100 Subject: [PATCH] Decrease min length username to 3 and make it more accessible through a constant --- internal/configuration/Configuration.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/configuration/Configuration.go b/internal/configuration/Configuration.go index 9092508..0168acb 100644 --- a/internal/configuration/Configuration.go +++ b/internal/configuration/Configuration.go @@ -26,6 +26,9 @@ const defaultPort = "53842" // Min length of admin password in characters const minLengthPassword = 6 +// Min length of admin username in characters +const minLengthUsername = 3 + // Environment is an object containing the environment variables var Environment environment.Environment @@ -243,10 +246,10 @@ func askForUsername(try int) string { return envUsername } username := helper.ReadLine() - if len(username) >= 4 { + if utf8.RuneCountInString(username) >= minLengthUsername { return username } - fmt.Println("Username needs to be at least 4 characters long") + fmt.Println("Username needs to be at least " + strconv.Itoa(minLengthUsername) + " characters long") return askForUsername(try + 1) }