mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
refactor(be): simplify ldap auth code
This commit is contained in:
parent
31e532548b
commit
3eb55aacd6
14
api/login.go
14
api/login.go
@ -165,17 +165,15 @@ func login(w http.ResponseWriter, r *http.Request) {
|
||||
user, err := helpers.Store(r).GetUserByLoginOrEmail(login.Auth, login.Auth)
|
||||
|
||||
if err == db.ErrNotFound {
|
||||
if ldapUser != nil {
|
||||
// create new LDAP user
|
||||
user, err = helpers.Store(r).CreateUserWithoutPassword(*ldapUser)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} else {
|
||||
if ldapUser == nil {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
} else if err != nil {
|
||||
|
||||
user, err = helpers.Store(r).CreateUserWithoutPassword(*ldapUser)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user