diff options
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/auth.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/modules/auth/auth.go b/modules/auth/auth.go index 1a7606a790..da89c20c1b 100644 --- a/modules/auth/auth.go +++ b/modules/auth/auth.go @@ -25,21 +25,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 { return 0 } - uid := sess.Get("uid") - if uid == nil { - return 0 - } - if id, ok := uid.(int64); ok { - if _, err := models.GetUserById(id); err != nil { - if err != models.ErrUserNotExist { - log.Error(4, "GetUserById: %v", err) - } - return 0 - } - return id - } - - // API calls also need to check access token. + // API calls need to check access token. if strings.HasPrefix(req.URL.Path, "/api/") { auHead := req.Header.Get("Authorization") if len(auHead) > 0 { @@ -56,6 +42,20 @@ func SignedInId(req *http.Request, sess session.Store) int64 { } } } + + uid := sess.Get("uid") + if uid == nil { + return 0 + } + if id, ok := uid.(int64); ok { + if _, err := models.GetUserById(id); err != nil { + if err != models.ErrUserNotExist { + log.Error(4, "GetUserById: %v", err) + } + return 0 + } + return id + } return 0 } |