From 24d7a86a8d35aa1fadf05deaa10e141d33ea6632 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 18 Aug 2015 21:34:03 -0700 Subject: 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. --- models/login.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'models') 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) -- cgit v1.2.3