summaryrefslogtreecommitdiffstats
path: root/routers/user/setting/security.go
diff options
context:
space:
mode:
authorDavid Schneiderbauer <daviian@users.noreply.github.com>2018-06-18 20:24:45 +0200
committertechknowlogick <techknowlogick@users.noreply.github.com>2018-06-18 14:24:45 -0400
commit69bfd81b1cc4b95d6bc49e7b027d2e5ff03167a5 (patch)
treeeafbcecfa86dd1e636dbbfcfbb3ed54c83e91027 /routers/user/setting/security.go
parent6e39f3d422155293a06df6430766a40ebc56277c (diff)
downloadgitea-69bfd81b1cc4b95d6bc49e7b027d2e5ff03167a5.tar.gz
gitea-69bfd81b1cc4b95d6bc49e7b027d2e5ff03167a5.zip
fix missing data on redirects (#3975)
Diffstat (limited to 'routers/user/setting/security.go')
-rw-r--r--routers/user/setting/security.go44
1 files changed, 24 insertions, 20 deletions
diff --git a/routers/user/setting/security.go b/routers/user/setting/security.go
index 860730303f..862e4413c7 100644
--- a/routers/user/setting/security.go
+++ b/routers/user/setting/security.go
@@ -22,6 +22,30 @@ func Security(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSecurity"] = true
+ if ctx.Query("openid.return_to") != "" {
+ settingsOpenIDVerify(ctx)
+ return
+ }
+
+ loadSecurityData(ctx)
+
+ ctx.HTML(200, tplSettingsSecurity)
+}
+
+// DeleteAccountLink delete a single account link
+func DeleteAccountLink(ctx *context.Context) {
+ if _, err := models.RemoveAccountLink(ctx.User, ctx.QueryInt64("loginSourceID")); err != nil {
+ ctx.Flash.Error("RemoveAccountLink: " + err.Error())
+ } else {
+ ctx.Flash.Success(ctx.Tr("settings.remove_account_link_success"))
+ }
+
+ ctx.JSON(200, map[string]interface{}{
+ "redirect": setting.AppSubURL + "/user/settings/security",
+ })
+}
+
+func loadSecurityData(ctx *context.Context) {
enrolled := true
_, err := models.GetTwoFactorByUID(ctx.User.ID)
if err != nil {
@@ -71,30 +95,10 @@ func Security(ctx *context.Context) {
}
ctx.Data["AccountLinks"] = sources
- if ctx.Query("openid.return_to") != "" {
- settingsOpenIDVerify(ctx)
- return
- }
-
openid, err := models.GetUserOpenIDs(ctx.User.ID)
if err != nil {
ctx.ServerError("GetUserOpenIDs", err)
return
}
ctx.Data["OpenIDs"] = openid
-
- ctx.HTML(200, tplSettingsSecurity)
-}
-
-// DeleteAccountLink delete a single account link
-func DeleteAccountLink(ctx *context.Context) {
- if _, err := models.RemoveAccountLink(ctx.User, ctx.QueryInt64("loginSourceID")); err != nil {
- ctx.Flash.Error("RemoveAccountLink: " + err.Error())
- } else {
- ctx.Flash.Success(ctx.Tr("settings.remove_account_link_success"))
- }
-
- ctx.JSON(200, map[string]interface{}{
- "redirect": setting.AppSubURL + "/user/settings/security",
- })
}