diff options
author | Girish Ramakrishnan <girish@cloudron.io> | 2015-08-18 21:34:03 -0700 |
---|---|---|
committer | Girish Ramakrishnan <girish@cloudron.io> | 2015-08-18 23:49:12 -0700 |
commit | 24d7a86a8d35aa1fadf05deaa10e141d33ea6632 (patch) | |
tree | 81f20ad9fa63e815ae0accf59a39eca2252b6068 /models/login.go | |
parent | 03b85b73af03eae98308fc3d36cdbd47db1503d6 (diff) | |
download | gitea-24d7a86a8d35aa1fadf05deaa10e141d33ea6632.tar.gz gitea-24d7a86a8d35aa1fadf05deaa10e141d33ea6632.zip |
Set IsAdmin using LDAP
The IsAdmin flag is set based on whether the admin filter
returned any result. The admin filter is applied with the user dn
as the search root.
In the future, we should update IsAdmin as well on each login.
Alternately, we can have a periodic sync operation.
Diffstat (limited to 'models/login.go')
-rw-r--r-- | models/login.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/models/login.go b/models/login.go index 8ac4b827ef..78a607263f 100644 --- a/models/login.go +++ b/models/login.go @@ -257,7 +257,7 @@ func UserSignIn(uname, passwd string) (*User, error) { // Return the same LoginUserPlain semantic // FIXME: https://github.com/gogits/gogs/issues/672 func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAPConfig, autoRegister bool) (*User, error) { - fn, sn, mail, logged := cfg.Ldapsource.SearchEntry(name, passwd) + fn, sn, mail, admin, logged := cfg.Ldapsource.SearchEntry(name, passwd) if !logged { // User not in LDAP, do nothing return nil, ErrUserNotExist{0, name} @@ -281,6 +281,7 @@ func LoginUserLdapSource(u *User, name, passwd string, sourceId int64, cfg *LDAP LoginName: name, Passwd: passwd, Email: mail, + IsAdmin: admin, IsActive: true, } return u, CreateUser(u) |