refactor(be): simplify ldap auth code

This commit is contained in:
Denis Gukov 2022-10-30 20:57:08 +05:00
parent 31e532548b
commit 3eb55aacd6

View File

@ -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)
}