Feature: Social sign in

tokarchuk/v1.17
Unknwon 11 years ago
parent 78defd238c
commit 5605af973b
  1. 1
      conf/locale/locale_zh-CN.ini
  2. 6
      modules/base/template.go
  3. 6
      routers/user/social.go

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

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

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

Loading…
Cancel
Save