diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-07 12:56:40 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-07 12:56:40 -0400 |
commit | 9ea9818d3255e5b08293205e278240dece36687d (patch) | |
tree | 51c6a65586843082f451ee1e93082fec5784ccd2 /routers/user | |
parent | 05fb34eacdbec59fb8bcdf96c82c0855e6ec78d2 (diff) | |
download | gitea-9ea9818d3255e5b08293205e278240dece36687d.tar.gz gitea-9ea9818d3255e5b08293205e278240dece36687d.zip |
Fix issue with log in with GitHub but need more error handle after
Diffstat (limited to 'routers/user')
-rw-r--r-- | routers/user/social.go | 12 | ||||
-rw-r--r-- | routers/user/user.go | 5 |
2 files changed, 13 insertions, 4 deletions
diff --git a/routers/user/social.go b/routers/user/social.go index f5577d809b..08cfcd83f2 100644 --- a/routers/user/social.go +++ b/routers/user/social.go @@ -1,20 +1,20 @@ // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. + package user import ( "encoding/json" "strconv" + "code.google.com/p/goauth2/oauth" + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/log" "github.com/gogits/gogs/modules/middleware" - //"github.com/gogits/gogs/modules/oauth2" - - "code.google.com/p/goauth2/oauth" - "github.com/martini-contrib/oauth2" + "github.com/gogits/gogs/modules/oauth2" ) type SocialConnector interface { @@ -80,6 +80,10 @@ func SocialSignIn(ctx *middleware.Context, tokens oauth2.Tokens) { Extra: tokens.ExtraData(), }, } + if len(tokens.Access()) == 0 { + log.Error("empty access") + return + } var err error var u *models.User if err = gh.Update(); err != nil { diff --git a/routers/user/user.go b/routers/user/user.go index 12f2bd8c51..f6a39b86c7 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -78,6 +78,11 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) { ctx.Data["Title"] = "Log In" if ctx.Req.Method == "GET" { + if base.OauthService != nil { + ctx.Data["OauthEnabled"] = true + ctx.Data["OauthGitHubEnabled"] = base.OauthService.GitHub.Enabled + } + // Check auto-login. userName := ctx.GetCookie(base.CookieUserName) if len(userName) == 0 { |