Browse Source

Fix reset user's email address display

Previously, this had bad template logic and showed the wrong email address.

Ref T695
pull/192/head
Matt Baer 4 years ago
parent
commit
a9b5bb2f6b
2 changed files with 8 additions and 8 deletions
  1. +7
    -7
      admin.go
  2. +1
    -1
      templates/user/admin/view-user.tmpl

+ 7
- 7
admin.go View File

@@ -184,19 +184,19 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque
Colls: []inspectedCollection{},
}

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 = u.EmailClear(app.keys)
p.ClearEmail = p.User.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)}
}
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)


+ 1
- 1
templates/user/admin/view-user.tmpl View File

@@ -23,7 +23,7 @@ input.copy-text {
<p>This user's password has been reset to:</p>
<p><input type="text" class="copy-text" value="{{.NewPassword}}" onfocus="if (this.select) this.select(); else this.setSelectionRange(0, this.value.length);" readonly /></p>
<p>They can use this new password to log in to their account. <strong>This will only be shown once</strong>, so be sure to copy it and send it to them now.</p>
{{if .User.Email}}<p>Their email address is: <a href="mailto:{{.ClearEmail}}">{{.ClearEmail}}</a></p>{{end}}
{{if .ClearEmail}}<p>Their email address is: <a href="mailto:{{.ClearEmail}}">{{.ClearEmail}}</a></p>{{end}}
</div>
{{end}}
<table class="classy export">


Loading…
Cancel
Save