diff options
Diffstat (limited to 'pkg/auth/auth.go')
-rw-r--r-- | pkg/auth/auth.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index a52ef958..ba9ccce1 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -15,8 +15,8 @@ import ( "github.com/gogits/gogs/models" "github.com/gogits/gogs/models/errors" - "github.com/gogits/gogs/pkg/tool" "github.com/gogits/gogs/pkg/setting" + "github.com/gogits/gogs/pkg/tool" ) func IsAPIPath(url string) bool { @@ -24,17 +24,20 @@ func IsAPIPath(url string) bool { } // SignedInID returns the id of signed in user. -func SignedInID(ctx *macaron.Context, sess session.Store) int64 { +func SignedInID(c *macaron.Context, sess session.Store) int64 { if !models.HasEngine { return 0 } // Check access token. - if IsAPIPath(ctx.Req.URL.Path) { - tokenSHA := ctx.Query("token") + if IsAPIPath(c.Req.URL.Path) { + tokenSHA := c.Query("token") + if len(tokenSHA) <= 0 { + tokenSHA = c.Query("access_token") + } if len(tokenSHA) == 0 { // Well, check with header again. - auHead := ctx.Req.Header.Get("Authorization") + auHead := c.Req.Header.Get("Authorization") if len(auHead) > 0 { auths := strings.Fields(auHead) if len(auths) == 2 && auths[0] == "token" { |