Skip to content

Commit 20b7ca8

Browse files
committed
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
1 parent 7ed00b6 commit 20b7ca8

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

routers/user/auth.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,9 @@ func ForgotPasswd(ctx *context.Context) {
872872
return
873873
}
874874

875+
email := ctx.Query("email")
876+
ctx.Data["Email"] = email
877+
875878
ctx.Data["IsResetRequest"] = true
876879
ctx.HTML(200, tplForgotPassword)
877880
}

routers/user/setting.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,15 @@ func SettingsDeleteAvatar(ctx *context.Context) {
193193
func SettingsPassword(ctx *context.Context) {
194194
ctx.Data["Title"] = ctx.Tr("settings")
195195
ctx.Data["PageIsSettingsPassword"] = true
196+
ctx.Data["Email"] = ctx.User.Email
196197
ctx.HTML(200, tplSettingsPassword)
197198
}
198199

199200
// SettingsPasswordPost response for change user's password
200201
func SettingsPasswordPost(ctx *context.Context, form auth.ChangePasswordForm) {
201202
ctx.Data["Title"] = ctx.Tr("settings")
202203
ctx.Data["PageIsSettingsPassword"] = true
204+
ctx.Data["PageIsSettingsDelete"] = true
203205

204206
if ctx.HasError() {
205207
ctx.HTML(200, tplSettingsPassword)
@@ -684,6 +686,7 @@ func SettingsDeleteAccountLink(ctx *context.Context) {
684686
func SettingsDelete(ctx *context.Context) {
685687
ctx.Data["Title"] = ctx.Tr("settings")
686688
ctx.Data["PageIsSettingsDelete"] = true
689+
ctx.Data["Email"] = ctx.User.Email
687690

688691
if ctx.Req.Method == "POST" {
689692
if _, err := models.UserSignIn(ctx.User.Name, ctx.Query("password")); err != nil {

templates/user/settings/delete.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<div class="ui red button delete-button" data-type="form" data-form="#delete-form">
2323
{{.i18n.Tr "settings.confirm_delete_account"}}
2424
</div>
25+
<div>
26+
<a href="{{AppSubUrl}}/user/forget_password?email={{.Email}}">{{.i18n.Tr "auth.forget_password"}}</a>
27+
</div>
2528
</form>
2629
</div>
2730
</div>

templates/user/settings/password.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
<div class="field">
3131
<button class="ui green button">{{$.i18n.Tr "settings.change_password"}}</button>
32+
<a href="{{AppSubUrl}}/user/forget_password?email={{.Email}}">{{.i18n.Tr "auth.forget_password"}}</a>
3233
</div>
3334
</form>
3435
{{else}}

0 commit comments

Comments
 (0)