1
0

when ID = 0 is passed to a 'GetSthByID'-function, it now returns a 'not exist' error

This commit is contained in:
kolaente
2018-09-13 20:07:11 +02:00
parent 716b06feff
commit 382daac0dd
9 changed files with 25 additions and 9 deletions

View File

@ -48,8 +48,8 @@ func (apiUser *APIUserPassword) APIFormat() User {
// GetUserByID gets informations about a user by its ID
func GetUserByID(id int64) (user User, err error) {
// Apparently xorm does otherwise look for all users but return only one, which leads to returing one even if the ID is 0
if id == 0 {
return User{}, nil
if id < 1 {
return User{}, ErrUserDoesNotExist{}
}
return GetUser(User{ID: id})