1
0
mirror of https://git.tuxpa.in/a/code-server.git synced 2024-12-27 04:35:25 +00:00

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 id="base" type="hidden" name="base" value="/" />
<div class="field">
<!-- The onfocus code places the cursor at the end of the value. -->
<input
required
autofocus
value="{{VALUE}}"
onfocus="const value=this.value;this.value='';this.value=value;"
class="password"
type="password"
placeholder="PASSWORD"

View File

@ -45,11 +45,9 @@ export class LoginHttpProvider extends HttpProvider {
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")
response.content = response.content
.replace(/{{VALUE}}/, value || "")
.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : "")
response.content = response.content.replace(/{{ERROR}}/, error ? `<div class="error">${error.message}</div>` : "")
return this.replaceTemplates(route, response)
}
@ -63,15 +61,12 @@ export class LoginHttpProvider extends HttpProvider {
return { code: HttpCode.Ok }
}
let payload: LoginPayload | undefined
try {
const data = await this.getData(request)
const p = data ? querystring.parse(data) : {}
payload = p
return await this.login(p, route, request)
const payload = data ? querystring.parse(data) : {}
return await this.login(payload, route, request)
} catch (error) {
return this.getRoot(route, payload ? payload.password : undefined, error)
return this.getRoot(route, error)
}
}