diff options
author | Unknown <joe2010xtmf@163.com> | 2014-06-24 13:55:47 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-06-24 13:55:47 -0400 |
commit | b2801a2e985f11e940a0cd420cea57242ea26d4c (patch) | |
tree | 4d245376952e5800411043c0ebed021c89c489ea /modules/auth | |
parent | ceb415df8a5ba9e33840df5d635765424a2bee8e (diff) | |
download | gitea-b2801a2e985f11e940a0cd420cea57242ea26d4c.tar.gz gitea-b2801a2e985f11e940a0cd420cea57242ea26d4c.zip |
Fix #165
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/user.go | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/modules/auth/user.go b/modules/auth/user.go index 284a4644de..20f9933626 100644 --- a/modules/auth/user.go +++ b/modules/auth/user.go @@ -25,23 +25,25 @@ func SignedInId(header http.Header, sess session.SessionStore) int64 { return 0 } - var id int64 if setting.Service.EnableReverseProxyAuth { - id, _ = base.StrTo(header.Get(setting.ReverseProxyAuthUid)).Int64() - } - - if id <= 0 { - uid := sess.Get("userId") - if uid == nil { - return 0 - } - var ok bool - if id, ok = uid.(int64); !ok { - return 0 + webAuthUser := header.Get(setting.ReverseProxyAuthUser) + if len(webAuthUser) > 0 { + u, err := models.GetUserByName(webAuthUser) + if err != nil { + if err != models.ErrUserNotExist { + log.Error("auth.user.SignedInId(GetUserByName): %v", err) + } + return 0 + } + return u.Id } } - if id > 0 { + uid := sess.Get("userId") + if uid == nil { + return 0 + } + if id, ok := uid.(int64); ok { if _, err := models.GetUserById(id); err != nil { if err != models.ErrUserNotExist { log.Error("auth.user.SignedInId(GetUserById): %v", err) |