diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-13 02:32:18 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-13 02:32:18 -0500 |
commit | 8eb5120fbd19dac1221f82d84c339b4be9b0975b (patch) | |
tree | 3238704d9968d41f3f871adda4c280e3bd73685d /modules/auth/auth.go | |
parent | 8c9338a5377c60c84cdee1f5781b3de5933bb3b0 (diff) | |
download | gitea-8eb5120fbd19dac1221f82d84c339b4be9b0975b.tar.gz gitea-8eb5120fbd19dac1221f82d84c339b4be9b0975b.zip |
#12, API: list user repos, list repo hooks
Diffstat (limited to 'modules/auth/auth.go')
-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 } |