models/login_source: add check for user for create/update on LDAP (#4405)

* Add check for user for create/update

* Update login_source.go

* Update login_source.go
pull/4527/head
Jon Lundy 2017-05-21 00:14:28 -06:00 committed by 无闻
parent 1a4ba4c390
commit 1755025e7f
1 changed files with 10 additions and 0 deletions

View File

@ -327,6 +327,16 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
IsActive: true,
IsAdmin: isAdmin,
}
ok, err := IsUserExist(0, user.Name)
if err != nil {
return user, err
}
if ok {
return user, UpdateUser(user)
}
return user, CreateUser(user)
}