Fixed creating of new users
This commit is contained in:
parent
906aee8b7d
commit
245259216f
3 changed files with 8 additions and 7 deletions
|
@ -81,6 +81,6 @@ func TestTeamList(t *testing.T) {
|
|||
// Delete with a nonexistant list
|
||||
err = tl4.Delete()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrListDoesNotExist(err))
|
||||
assert.True(t, IsErrTeamDoesNotHaveAccessToList(err))
|
||||
|
||||
}
|
||||
|
|
|
@ -79,6 +79,6 @@ func TestTeamNamespace(t *testing.T) {
|
|||
// Try deleting with a nonexistant namespace
|
||||
err = tn4.Delete()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrNamespaceDoesNotExist(err))
|
||||
assert.True(t, IsErrTeamDoesNotHaveAccessToNamespace(err))
|
||||
|
||||
}
|
||||
|
|
|
@ -15,24 +15,25 @@ func CreateUser(user User) (newUser User, err error) {
|
|||
}
|
||||
|
||||
// Check if the user already existst with that username
|
||||
var exists bool
|
||||
exists := true
|
||||
existingUser, err := GetUser(User{Username: newUser.Username})
|
||||
if err != nil {
|
||||
if IsErrUserDoesNotExist(err) {
|
||||
exists = true
|
||||
exists = false
|
||||
} else {
|
||||
return User{}, err
|
||||
}
|
||||
}
|
||||
if exists {
|
||||
return User{}, ErrUsernameExists{existingUser.ID, existingUser.Username}
|
||||
return User{}, ErrUsernameExists{newUser.ID, newUser.Username}
|
||||
}
|
||||
|
||||
// Check if the user already existst with that email
|
||||
exists = true
|
||||
existingUser, err = GetUser(User{Email: newUser.Email})
|
||||
if err != nil && !IsErrUserDoesNotExist(err) {
|
||||
if err != nil {
|
||||
if IsErrUserDoesNotExist(err) {
|
||||
exists = true
|
||||
exists = false
|
||||
} else {
|
||||
return User{}, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue