1
0

fix: check if usernames contain spaces when creating a new user

This commit is contained in:
kolaente
2023-03-12 15:02:34 +01:00
parent 1f13b5d7b4
commit 672fb35bcb
4 changed files with 69 additions and 19 deletions

View File

@ -17,6 +17,8 @@
package user
import (
"strings"
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/notifications"
@ -33,7 +35,7 @@ func CreateUser(s *xorm.Session, user *User) (newUser *User, err error) {
user.Issuer = IssuerLocal
}
// Check if we have all needed information
// Check if we have all required information
err = checkIfUserIsValid(user)
if err != nil {
return nil, err
@ -128,6 +130,12 @@ func checkIfUserIsValid(user *User) error {
return ErrNoUsernamePassword{}
}
if strings.Contains(user.Username, " ") {
return &ErrUsernameMustNotContainSpaces{
Username: user.Username,
}
}
return nil
}