diff --git a/pkg/user/helper.go b/pkg/user/helper.go index c26f2a1..f1b195f 100644 --- a/pkg/user/helper.go +++ b/pkg/user/helper.go @@ -13,22 +13,15 @@ const ( ) var ( - lowerCharSet = "abcdedfghijklmnopqrst" - upperCharSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - specialCharSet = "!@#$%&*" - numberSet = "0123456789" - allCharSet = lowerCharSet + upperCharSet + specialCharSet + numberSet + lowerCharSet = "abcdedfghijklmnopqrst" + upperCharSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + numberSet = "0123456789" + allCharSet = lowerCharSet + upperCharSet + numberSet ) -func generateRandomPassword(passwordLength, minSpecialChar, minNum, minUpperCase int) string { +func generateRandomPassword(passwordLength, minNum, minUpperCase int) string { var pb strings.Builder - // Set special character - for i := 0; i < minSpecialChar; i++ { - random := rand.Intn(len(specialCharSet)) - pb.WriteString(string(specialCharSet[random])) - } - // Set numeric for i := 0; i < minNum; i++ { random := rand.Intn(len(numberSet)) @@ -41,7 +34,7 @@ func generateRandomPassword(passwordLength, minSpecialChar, minNum, minUpperCase pb.WriteString(string(upperCharSet[random])) } - remainingLength := passwordLength - minSpecialChar - minNum - minUpperCase + remainingLength := passwordLength - minNum - minUpperCase for i := 0; i < remainingLength; i++ { random := rand.Intn(len(allCharSet)) pb.WriteString(string(allCharSet[random])) diff --git a/pkg/user/service.go b/pkg/user/service.go index 2aa60ff..4351f60 100644 --- a/pkg/user/service.go +++ b/pkg/user/service.go @@ -153,7 +153,7 @@ func (s *service) initializeInitialUser(ctx context.Context, email string, passw email = "admin@example.com" } if password == "" || password == "random" { - password = generateRandomPassword(16, 0, 4, 4) + password = generateRandomPassword(32, 4, 4) generatedRandomPassword = true } createdUser, err := s.CreateUser(ctx, &CreateOptions{