Check user != nil before checking values (#9881)
* Check user != nil before checking values * Handle autoAdmin
This commit is contained in:
parent
bec99507a4
commit
dcf7e858cb
1 changed files with 15 additions and 7 deletions
|
@ -473,7 +473,14 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
|
||||||
// Update User admin flag if exist
|
// Update User admin flag if exist
|
||||||
if isExist, err := IsUserExist(0, sr.Username); err != nil {
|
if isExist, err := IsUserExist(0, sr.Username); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
} else if isExist &&
|
} else if isExist {
|
||||||
|
if user == nil {
|
||||||
|
user, err = GetUserByName(sr.Username)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if user != nil &&
|
||||||
!user.ProhibitLogin && len(source.LDAP().AdminFilter) > 0 && user.IsAdmin != sr.IsAdmin {
|
!user.ProhibitLogin && len(source.LDAP().AdminFilter) > 0 && user.IsAdmin != sr.IsAdmin {
|
||||||
// Change existing admin flag only if AdminFilter option is set
|
// Change existing admin flag only if AdminFilter option is set
|
||||||
user.IsAdmin = sr.IsAdmin
|
user.IsAdmin = sr.IsAdmin
|
||||||
|
@ -482,6 +489,7 @@ func LoginViaLDAP(user *User, login, password string, source *LoginSource, autoR
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !autoRegister {
|
if !autoRegister {
|
||||||
if isAttributeSSHPublicKeySet && synchronizeLdapSSHPublicKeys(user, source, sr.SSHPublicKey) {
|
if isAttributeSSHPublicKeySet && synchronizeLdapSSHPublicKeys(user, source, sr.SSHPublicKey) {
|
||||||
|
|
Loading…
Reference in a new issue