mirror of
1
Fork 0

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 = 探索
help = 帮助
sign_in = 登录
social_sign_in = 社交帐号登录:第 2 步 <small>关联帐号</small>
sign_out = 退出
sign_up = 注册
register = 注册

View File

@ -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"
}

View File

@ -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
}