validation: improve error message for invalid chars

This commit is contained in:
Nicola Murino
2021-02-08 21:32:59 +01:00
parent a2a99f9b57
commit db80781716
3 changed files with 5 additions and 5 deletions

View File

@@ -70,7 +70,7 @@ func (a *Admin) validate() error {
return &ValidationError{err: "please set a password"}
}
if !usernameRegex.MatchString(a.Username) {
return &ValidationError{err: fmt.Sprintf("username %#v is not valid", a.Username)}
return &ValidationError{err: fmt.Sprintf("username %#v is not valid, the following characters are allowed: a-zA-Z0-9-_.~", a.Username)}
}
if a.Password != "" && !strings.HasPrefix(a.Password, argonPwdPrefix) {
pwd, err := argon2id.CreateHash(a.Password, argon2Params)