1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-08-10 13:46:46 +02:00

Ensure that a username starts with a letter

The docstring for ValidateUsername() states:

  It must be at least 2 characters long, start with a letter, and
  contain only letters, numbers, hyphens, dots, and underscores.
This commit is contained in:
Florian Preinstorfer 2025-05-29 14:57:21 +02:00
parent 081af2674b
commit 7e14d4b4e5

View File

@ -37,9 +37,9 @@ func ValidateUsername(username string) error {
return errors.New("username must be at least 2 characters long")
}
// Ensure the username does not start with a number
if unicode.IsDigit(rune(username[0])) {
return errors.New("username cannot start with a number")
// Ensure the username starts with a letter
if !unicode.IsLetter(rune(username[0])) {
return errors.New("username must start with a letter")
}
atCount := 0