From 5605af973b440add79b1c32c911bee03fa821a4e Mon Sep 17 00:00:00 2001 From: Unknwon Date: Sat, 9 Aug 2014 18:01:29 -0700 Subject: [PATCH] Feature: Social sign in --- conf/locale/locale_zh-CN.ini | 1 + modules/base/template.go | 6 +++--- routers/user/social.go | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 31b99c6024..8aec50092c 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -5,6 +5,7 @@ dashboard = 控制面板 explore = 探索 help = 帮助 sign_in = 登录 +social_sign_in = 社交帐号登录:第 2 步 关联帐号 sign_out = 退出 sign_up = 注册 register = 注册 diff --git a/modules/base/template.go b/modules/base/template.go index 51b1dfff01..f2ae00b915 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -241,7 +241,7 @@ func Oauth2Icon(t int) string { case 3: return "fa-twitter-square" case 4: - return "fa-linux" + return "fa-qq" case 5: return "fa-weibo" } @@ -253,11 +253,11 @@ func Oauth2Name(t int) string { case 1: return "GitHub" case 2: - return "Google" + return "Google+" case 3: return "Twitter" case 4: - return "Tencent QQ" + return "腾讯 QQ" case 5: return "Weibo" } diff --git a/routers/user/social.go b/routers/user/social.go index d7486dad2b..07c6deed6d 100644 --- a/routers/user/social.go +++ b/routers/user/social.go @@ -40,11 +40,15 @@ func SocialSignIn(ctx *middleware.Context) { ctx.Handle(404, "social.SocialSignIn(social login not enabled)", errors.New(name)) return } + appUrl := strings.TrimSuffix(setting.AppUrl, "/") + if name == "weibo" { + appUrl = strings.Replace(appUrl, "localhost", "127.0.0.1", 1) + } code := ctx.Query("code") if code == "" { // redirect to social login page - connect.SetRedirectUrl(strings.TrimSuffix(setting.AppUrl, "/") + ctx.Req.URL.Path) + connect.SetRedirectUrl(appUrl + ctx.Req.URL.Path) ctx.Redirect(connect.AuthCodeURL(next)) return }