|
|
|
|
@ -21,6 +21,10 @@ import (
@@ -21,6 +21,10 @@ import (
|
|
|
|
|
"github.com/gogits/gogs/modules/uuid" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func IsAPIPath(url string) bool { |
|
|
|
|
return strings.HasPrefix(url, "/api/") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SignedInId returns the id of signed in user.
|
|
|
|
|
func SignedInId(req *http.Request, sess session.Store) int64 { |
|
|
|
|
if !models.HasEngine { |
|
|
|
|
@ -28,7 +32,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
@@ -28,7 +32,7 @@ func SignedInId(req *http.Request, sess session.Store) int64 {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// API calls need to check access token.
|
|
|
|
|
if strings.HasPrefix(req.URL.Path, "/api/") { |
|
|
|
|
if IsAPIPath(req.URL.Path) { |
|
|
|
|
auHead := req.Header.Get("Authorization") |
|
|
|
|
if len(auHead) > 0 { |
|
|
|
|
auths := strings.Fields(auHead) |
|
|
|
|
|