forked from forgejo/forgejo
Fix #165
This commit is contained in:
parent
ceb415df8a
commit
b2801a2e98
10 changed files with 264 additions and 269 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue