Fix false login state on failed login

Previously, a failed login would change the site-wide navigation so that
it looked like the user was logged in, even though they weren't. This
fixes that.
This commit is contained in:
Matt Baer 2019-09-03 17:56:27 -04:00
parent 8ec25f1fb4
commit 4419632f83
2 changed files with 6 additions and 6 deletions

View File

@ -309,10 +309,10 @@ func viewLogin(app *App, w http.ResponseWriter, r *http.Request) error {
p := &struct {
page.StaticPage
To string
Message template.HTML
Flashes []template.HTML
Username string
To string
Message template.HTML
Flashes []template.HTML
LoginUsername string
}{
pageForReq(app, r),
r.FormValue("to"),

View File

@ -12,8 +12,8 @@
</ul>{{end}}
<form action="/auth/login" method="post" style="text-align: center;margin-top:1em;" onsubmit="disableSubmit()">
<input type="text" name="alias" placeholder="Username" value="{{.Username}}" {{if not .Username}}autofocus{{end}} /><br />
<input type="password" name="pass" placeholder="Password" {{if .Username}}autofocus{{end}} /><br />
<input type="text" name="alias" placeholder="Username" value="{{.LoginUsername}}" {{if not .LoginUsername}}autofocus{{end}} /><br />
<input type="password" name="pass" placeholder="Password" {{if .LoginUsername}}autofocus{{end}} /><br />
{{if .To}}<input type="hidden" name="to" value="{{.To}}" />{{end}}
<input type="submit" id="btn-login" value="Login" />
</form>