Feature: Social sign in

This commit is contained in:
Unknwon 2014-08-09 18:01:29 -07:00
parent 78defd238c
commit 5605af973b
3 changed files with 9 additions and 4 deletions

View file

@ -5,6 +5,7 @@ dashboard = 控制面板
explore = 探索 explore = 探索
help = 帮助 help = 帮助
sign_in = 登录 sign_in = 登录
social_sign_in = 社交帐号登录:第 2 步 <small>关联帐号</small>
sign_out = 退出 sign_out = 退出
sign_up = 注册 sign_up = 注册
register = 注册 register = 注册

View file

@ -241,7 +241,7 @@ func Oauth2Icon(t int) string {
case 3: case 3:
return "fa-twitter-square" return "fa-twitter-square"
case 4: case 4:
return "fa-linux" return "fa-qq"
case 5: case 5:
return "fa-weibo" return "fa-weibo"
} }
@ -253,11 +253,11 @@ func Oauth2Name(t int) string {
case 1: case 1:
return "GitHub" return "GitHub"
case 2: case 2:
return "Google" return "Google+"
case 3: case 3:
return "Twitter" return "Twitter"
case 4: case 4:
return "Tencent QQ" return "腾讯 QQ"
case 5: case 5:
return "Weibo" return "Weibo"
} }

View file

@ -40,11 +40,15 @@ func SocialSignIn(ctx *middleware.Context) {
ctx.Handle(404, "social.SocialSignIn(social login not enabled)", errors.New(name)) ctx.Handle(404, "social.SocialSignIn(social login not enabled)", errors.New(name))
return return
} }
appUrl := strings.TrimSuffix(setting.AppUrl, "/")
if name == "weibo" {
appUrl = strings.Replace(appUrl, "localhost", "127.0.0.1", 1)
}
code := ctx.Query("code") code := ctx.Query("code")
if code == "" { if code == "" {
// redirect to social login page // 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)) ctx.Redirect(connect.AuthCodeURL(next))
return return
} }