Don't write bad password back out to input

Closes #1379.
This commit is contained in:
Asher 2020-02-28 10:49:35 -06:00
parent 963ebaca5b
commit 0f87798ed6
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 5 additions and 13 deletions

View File

@ -33,12 +33,9 @@
<input class="user" type="text" autocomplete="username" /> <input class="user" type="text" autocomplete="username" />
<input id="base" type="hidden" name="base" value="/" /> <input id="base" type="hidden" name="base" value="/" />
<div class="field"> <div class="field">
<!-- The onfocus code places the cursor at the end of the value. -->
<input <input
required required
autofocus autofocus
value="{{VALUE}}"
onfocus="const value=this.value;this.value='';this.value=value;"
class="password" class="password"
type="password" type="password"
placeholder="PASSWORD" placeholder="PASSWORD"

View File

@ -45,11 +45,9 @@ export class LoginHttpProvider extends HttpProvider {
return undefined return undefined
} }
public async getRoot(route: Route, value?: string, error?: Error): Promise<HttpResponse> { public async getRoot(route: Route, error?: Error): Promise<HttpResponse> {
const response = await this.getUtf8Resource(this.rootPath, "src/browser/pages/login.html") const response = await this.getUtf8Resource(this.rootPath, "src/browser/pages/login.html")
response.content = response.content response.content = response.content.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : "")
.replace(/{{VALUE}}/, value || "")
.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : "")
return this.replaceTemplates(route, response) return this.replaceTemplates(route, response)
} }
@ -63,15 +61,12 @@ export class LoginHttpProvider extends HttpProvider {
return { code: HttpCode.Ok } return { code: HttpCode.Ok }
} }
let payload: LoginPayload | undefined
try { try {
const data = await this.getData(request) const data = await this.getData(request)
const p = data ? querystring.parse(data) : {} const payload = data ? querystring.parse(data) : {}
payload = p return await this.login(payload, route, request)
return await this.login(p, route, request)
} catch (error) { } catch (error) {
return this.getRoot(route, payload ? payload.password : undefined, error) return this.getRoot(route, error)
} }
} }