From 20b7ca884dd9fe11731a207ca11000a7c7e4bf0d Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Tue, 7 Feb 2017 21:18:03 +0100 Subject: [PATCH] Show a link to password reset from password change and delete account It's helpful when you forgot your password thus cannot change it (can happen if you log in via OAuth2 or OpenID) Also make sure that both the delete-account and password-change links to forgot-password will have the primary email pre-filled --- routers/user/auth.go | 3 +++ routers/user/setting.go | 3 +++ templates/user/settings/delete.tmpl | 3 +++ templates/user/settings/password.tmpl | 1 + 4 files changed, 10 insertions(+) diff --git a/routers/user/auth.go b/routers/user/auth.go index ed8aac0de97eb..cb7d5961bd4ec 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -872,6 +872,9 @@ func ForgotPasswd(ctx *context.Context) { return } + email := ctx.Query("email") + ctx.Data["Email"] = email + ctx.Data["IsResetRequest"] = true ctx.HTML(200, tplForgotPassword) } diff --git a/routers/user/setting.go b/routers/user/setting.go index 66ee680fb55e5..622f45f2c6881 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -193,6 +193,7 @@ func SettingsDeleteAvatar(ctx *context.Context) { func SettingsPassword(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsPassword"] = true + ctx.Data["Email"] = ctx.User.Email ctx.HTML(200, tplSettingsPassword) } @@ -200,6 +201,7 @@ func SettingsPassword(ctx *context.Context) { func SettingsPasswordPost(ctx *context.Context, form auth.ChangePasswordForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsPassword"] = true + ctx.Data["PageIsSettingsDelete"] = true if ctx.HasError() { ctx.HTML(200, tplSettingsPassword) @@ -684,6 +686,7 @@ func SettingsDeleteAccountLink(ctx *context.Context) { func SettingsDelete(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsDelete"] = true + ctx.Data["Email"] = ctx.User.Email if ctx.Req.Method == "POST" { if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil { diff --git a/templates/user/settings/delete.tmpl b/templates/user/settings/delete.tmpl index b95eb2105f130..67f5782d6ec75 100644 --- a/templates/user/settings/delete.tmpl +++ b/templates/user/settings/delete.tmpl @@ -22,6 +22,9 @@
{{.i18n.Tr "settings.confirm_delete_account"}}
+
+ {{.i18n.Tr "auth.forget_password"}} +
diff --git a/templates/user/settings/password.tmpl b/templates/user/settings/password.tmpl index b59d1ff56fde0..f4883d7bf06ef 100644 --- a/templates/user/settings/password.tmpl +++ b/templates/user/settings/password.tmpl @@ -29,6 +29,7 @@
+ {{.i18n.Tr "auth.forget_password"}}
{{else}}