From a9b5bb2f6baba201c561868fdb31aeca789853c7 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 11 Nov 2019 21:40:49 +0900 Subject: [PATCH] Fix reset user's email address display Previously, this had bad template logic and showed the wrong email address. Ref T695 --- admin.go | 16 ++++++++-------- templates/user/admin/view-user.tmpl | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/admin.go b/admin.go index 5f7d0c7..3b05bd4 100644 --- a/admin.go +++ b/admin.go @@ -184,19 +184,19 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque Colls: []inspectedCollection{}, } - flashes, _ := getSessionFlashes(app, w, r, nil) - for _, flash := range flashes { - if strings.HasPrefix(flash, "SUCCESS: ") { - p.NewPassword = strings.TrimPrefix(flash, "SUCCESS: ") - p.ClearEmail = u.EmailClear(app.keys) - } - } - var err error p.User, err = app.db.GetUserForAuth(username) if err != nil { return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not get user: %v", err)} } + + flashes, _ := getSessionFlashes(app, w, r, nil) + for _, flash := range flashes { + if strings.HasPrefix(flash, "SUCCESS: ") { + p.NewPassword = strings.TrimPrefix(flash, "SUCCESS: ") + p.ClearEmail = p.User.EmailClear(app.keys) + } + } p.UserPage = NewUserPage(app, r, u, p.User.Username, nil) p.TotalPosts = app.db.GetUserPostsCount(p.User.ID) lp, err := app.db.GetUserLastPostTime(p.User.ID) diff --git a/templates/user/admin/view-user.tmpl b/templates/user/admin/view-user.tmpl index 720a714..4157fca 100644 --- a/templates/user/admin/view-user.tmpl +++ b/templates/user/admin/view-user.tmpl @@ -23,7 +23,7 @@ input.copy-text {

This user's password has been reset to:

They can use this new password to log in to their account. This will only be shown once, so be sure to copy it and send it to them now.

- {{if .User.Email}}

Their email address is: {{.ClearEmail}}

{{end}} + {{if .ClearEmail}}

Their email address is: {{.ClearEmail}}

{{end}} {{end}}