Fix password validation issue during registration

This commit is contained in:
2024-09-03 13:46:28 +07:00
parent 8b050bc1da
commit d31688e1ba

View File

@ -66,25 +66,25 @@ func CheckPasswordHash(password, hash string) bool {
} }
func ValidatePassword(password string) bool { func ValidatePassword(password string) bool {
if len(password) < 6 { if len(password) < 8 {
return false return false
} }
var ( var (
hasNumber int hasNumber bool
hasUppercase bool hasUppercase bool
) )
for _, char := range password { for _, char := range password {
switch { switch {
case unicode.IsNumber(char): case unicode.IsNumber(char):
hasNumber++ hasNumber = true
case unicode.IsUpper(char): case unicode.IsUpper(char):
hasUppercase = true hasUppercase = true
} }
} }
return hasNumber >= 3 && hasUppercase return hasNumber && hasUppercase
} }
func ConvertFileSize(byte int64) string { func ConvertFileSize(byte int64) string {