Skip to content

Commit

Permalink
Revert "fixed username validator (goharbor#239)" (goharbor#247)
Browse files Browse the repository at this point in the history
This reverts commit d059ef2.
  • Loading branch information
Vad1mo authored Nov 11, 2024
1 parent d059ef2 commit cc8d1c8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/utils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ func FormatSize(size int64) string {
return fmt.Sprintf("%.2fMiB", mbSize)
}

// ValidateUserName checks if the username is valid by length and allowed characters.
func ValidateUserName(username string) bool {
username = strings.TrimSpace(username)
return len(username) >= 1 && len(username) <= 255 && !strings.ContainsAny(username, `,"~#%$`)
pattern := `^[a-zA-Z0-9]{1,255}$`
re := regexp.MustCompile(pattern)
return re.MatchString(username)
}

func ValidateEmail(email string) bool {
Expand Down

0 comments on commit cc8d1c8

Please sign in to comment.