mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
* Check user != nil before checking values * Handle autoAdmin Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
f2e9d4b851
commit
ce756ee89f
@ -473,13 +473,21 @@ 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 {
|
||||||
!user.ProhibitLogin && len(source.LDAP().AdminFilter) > 0 && user.IsAdmin != sr.IsAdmin {
|
if user == nil {
|
||||||
// Change existing admin flag only if AdminFilter option is set
|
user, err = GetUserByName(sr.Username)
|
||||||
user.IsAdmin = sr.IsAdmin
|
if err != nil {
|
||||||
err = UpdateUserCols(user, "is_admin")
|
return nil, err
|
||||||
if err != nil {
|
}
|
||||||
return nil, err
|
}
|
||||||
|
if user != nil &&
|
||||||
|
!user.ProhibitLogin && len(source.LDAP().AdminFilter) > 0 && user.IsAdmin != sr.IsAdmin {
|
||||||
|
// Change existing admin flag only if AdminFilter option is set
|
||||||
|
user.IsAdmin = sr.IsAdmin
|
||||||
|
err = UpdateUserCols(user, "is_admin")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user