Tweak admin user pass reset success copy

This also adjusts the style and includes the user's password, so the
admin can easily notify them.

Ref T695
This commit is contained in:
Matt Baer 2019-11-11 18:03:19 +09:00
parent f673f9b562
commit 422c16f39a
2 changed files with 12 additions and 13 deletions

View File

@ -177,6 +177,7 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque
LastPost string LastPost string
NewPassword string NewPassword string
TotalPosts int64 TotalPosts int64
ClearEmail string
}{ }{
Config: app.cfg.App, Config: app.cfg.App,
Message: r.FormValue("m"), Message: r.FormValue("m"),
@ -187,6 +188,7 @@ func handleViewAdminUser(app *App, u *User, w http.ResponseWriter, r *http.Reque
for _, flash := range flashes { for _, flash := range flashes {
if strings.HasPrefix(flash, "SUCCESS: ") { if strings.HasPrefix(flash, "SUCCESS: ") {
p.NewPassword = strings.TrimPrefix(flash, "SUCCESS: ") p.NewPassword = strings.TrimPrefix(flash, "SUCCESS: ")
p.ClearEmail = u.EmailClear(app.keys)
} }
} }

View File

@ -11,7 +11,8 @@ input.copy-text {
text-align: center; text-align: center;
font-size: 1.2em; font-size: 1.2em;
color: #555; color: #555;
margin-left: 1rem; width: 100%;
box-sizing: border-box;
} }
button[type="submit"].danger { button[type="submit"].danger {
padding-left: 2rem; padding-left: 2rem;
@ -22,16 +23,12 @@ button[type="submit"].danger {
{{template "admin-header" .}} {{template "admin-header" .}}
<h2 id="posts-header">{{.User.Username}}</h2> <h2 id="posts-header">{{.User.Username}}</h2>
{{if .NewPassword}}<p class="alert success">New password for user <strong>{{.User.Username}}</strong> is {{if .NewPassword}}<div class="alert success">
<input <p>This user's password has been reset to:</p>
type="text" <p><input type="text" class="copy-text" value="{{.NewPassword}}" onfocus="if (this.select) this.select(); else this.setSelectionRange(0, this.value.length);" readonly /></p>
class="copy-text" <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>
value="{{.NewPassword}}" {{if .User.Email}}<p>Their email address is: <a href="mailto:{{.ClearEmail}}">{{.ClearEmail}}</a></p>{{end}}
onfocus="if (this.select) this.select(); else this.setSelectionRange(0, this.value.length);" </div>
readonly />
<br/><br/>
You must share this new password with the user, this is the only time it will be displayed.
</p>
{{end}} {{end}}
<table class="classy export"> <table class="classy export">
<tr> <tr>