aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user/social.go
diff options
context:
space:
mode:
authorskyblue <ssx205@gmail.com>2014-04-13 01:15:19 +0800
committerskyblue <ssx205@gmail.com>2014-04-13 01:15:19 +0800
commit75d2affcbf9b26c5a989a75a6654d9b6e21415e9 (patch)
tree5263cd984360d58c4d44057892d9dd49c4aa529b /routers/user/social.go
parentf92851e347c6db6468555373bd43c7b507c5fce9 (diff)
downloadgitea-75d2affcbf9b26c5a989a75a6654d9b6e21415e9.tar.gz
gitea-75d2affcbf9b26c5a989a75a6654d9b6e21415e9.zip
add oauth2 qq support
Diffstat (limited to 'routers/user/social.go')
-rw-r--r--routers/user/social.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/routers/user/social.go b/routers/user/social.go
index cd5958aa08..ea47d71b14 100644
--- a/routers/user/social.go
+++ b/routers/user/social.go
@@ -28,7 +28,7 @@ type BasicUserInfo struct {
type SocialConnector interface {
Type() int
SetRedirectUrl(string)
- UserInfo(*oauth.Token) (*BasicUserInfo, error)
+ UserInfo(*oauth.Token, *url.URL) (*BasicUserInfo, error)
AuthCodeURL(string) string
Exchange(string) (*oauth.Token, error)
@@ -63,13 +63,13 @@ func SocialSignIn(params martini.Params, ctx *middleware.Context) {
code := ctx.Query("code")
if code == "" {
// redirect to social login page
- connect.SetRedirectUrl(strings.TrimSuffix(base.AppUrl, "/") + ctx.Req.URL.RequestURI())
+ connect.SetRedirectUrl(strings.TrimSuffix(base.AppUrl, "/") + ctx.Req.URL.Host + ctx.Req.URL.Path)
ctx.Redirect(connect.AuthCodeURL(next))
return
}
// handle call back
- tk, err := connect.Exchange(code) // transport.Exchange(code)
+ tk, err := connect.Exchange(code) // exchange for token
if err != nil {
log.Error("oauth2 handle callback error: %v", err)
ctx.Handle(500, "exchange code error", nil)
@@ -78,7 +78,7 @@ func SocialSignIn(params martini.Params, ctx *middleware.Context) {
next = extractPath(ctx.Query("state"))
log.Trace("success get token")
- ui, err := connect.UserInfo(tk)
+ ui, err := connect.UserInfo(tk, ctx.Req.URL)
if err != nil {
ctx.Handle(500, fmt.Sprintf("get infomation from %s error: %v", name, err), nil)
log.Error("social connect error: %s", err)