aboutsummaryrefslogtreecommitdiff
path: root/pkg/auth/auth.go
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2017-06-05 15:34:11 -0400
committerGitHub <noreply@github.com>2017-06-05 15:34:11 -0400
commit51d7f1264bc39a75b4fb016bee7d0f87f8485f3f (patch)
tree63ec5e3eff2ebcbfdc78a4d7649b41a230532e96 /pkg/auth/auth.go
parent3359b942b379bdfb7ae33b8c106c8b3bc8afbf52 (diff)
api: GitHub compliance (#4549)
* Add undocumented endpoint for /repositories/:id * GitHub API Compliance
Diffstat (limited to 'pkg/auth/auth.go')
-rw-r--r--pkg/auth/auth.go13
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" {