diff options
author | Unknown <joe2010xtmf@163.com> | 2014-04-13 21:00:12 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-04-13 21:00:12 -0400 |
commit | d2b53dd43b3bc9719985033bc92b76abb9515b4d (patch) | |
tree | f6c038f0b8c11e8a01d7cd26d6bbdb14144696b3 /routers | |
parent | 4b9b8024ba59b5b84d92dca650761b35ebf6408a (diff) | |
download | gitea-d2b53dd43b3bc9719985033bc92b76abb9515b4d.tar.gz gitea-d2b53dd43b3bc9719985033bc92b76abb9515b4d.zip |
Add weibo oauth
Diffstat (limited to 'routers')
-rw-r--r-- | routers/admin/admin.go | 6 | ||||
-rw-r--r-- | routers/user/setting.go | 24 |
2 files changed, 26 insertions, 4 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 18a43ff817..d0f737e645 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -153,6 +153,12 @@ func Config(ctx *middleware.Context) { ctx.Data["Mailer"] = base.MailService } + ctx.Data["OauthEnabled"] = false + if base.OauthService != nil { + ctx.Data["OauthEnabled"] = true + ctx.Data["Oauther"] = base.OauthService + } + ctx.Data["CacheAdapter"] = base.CacheAdapter ctx.Data["CacheConfig"] = base.CacheConfig diff --git a/routers/user/setting.go b/routers/user/setting.go index 7e66ad3599..a8fdc116c6 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -69,6 +69,20 @@ func SettingPost(ctx *middleware.Context, form auth.UpdateProfileForm) { ctx.Redirect("/user/setting") } +func SettingSocial(ctx *middleware.Context) { + ctx.Data["Title"] = "Social Account" + ctx.Data["PageIsUserSetting"] = true + ctx.Data["IsUserPageSettingSocial"] = true + socials, err := models.GetOauthByUserId(ctx.User.Id) + if err != nil { + ctx.Handle(500, "user.SettingSocial", err) + return + } + + ctx.Data["Socials"] = socials + ctx.HTML(200, "user/social") +} + func SettingPassword(ctx *middleware.Context) { ctx.Data["Title"] = "Password" ctx.Data["PageIsUserSetting"] = true @@ -147,7 +161,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) { // Add new SSH key. if ctx.Req.Method == "POST" { - if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) { + if ctx.HasError() { ctx.HTML(200, "user/publickey") return } @@ -162,11 +176,13 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) { ctx.RenderWithErr("Public key name has been used", "user/publickey", &form) return } - ctx.Handle(200, "ssh.AddPublicKey", err) - log.Trace("%s User SSH key added: %s", ctx.Req.RequestURI, ctx.User.LowerName) + ctx.Handle(500, "ssh.AddPublicKey", err) return } else { - ctx.Data["AddSSHKeySuccess"] = true + log.Trace("%s User SSH key added: %s", ctx.Req.RequestURI, ctx.User.LowerName) + ctx.Flash.Success("New SSH Key has been added!") + ctx.Redirect("/user/setting/ssh") + return } } |