Skip to content

Allow use of the enter key for password input for code-server #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 12, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions packages/app/browser/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@
</head>

<body>
<div class="login">
<div class="back"> <- Back </div>
<h4 class="title">code-server</h4>
<h2 class="subtitle">
Enter server password
</h2>
<div class="mdc-text-field">
<input type="password" id="password" class="mdc-text-field__input" required>
<label class="mdc-floating-label" for="password">Password</label>
<div class="mdc-line-ripple"></div>
</div>
<button id="submit" class="mdc-button mdc-button--unelevated">
<span class="mdc-button__label">Enter IDE</span>
</button>
<div id="error-display"></div>
</div>
<form id="login-form">
<div class="login">
<div class="back">
<- Back </div> <h4 class="title">code-server</h4>
<h2 class="subtitle">
Enter server password
</h2>
<div class="mdc-text-field">
<input type="password" id="password" class="mdc-text-field__input" required>
<label class="mdc-floating-label" for="password">Password</label>
<div class="mdc-line-ripple"></div>
</div>
<button id="submit" class="mdc-button mdc-button--unelevated">
<span class="mdc-button__label">Enter IDE</span>
</button>
<div id="error-display"></div>
</div>
</form>
</body>

</html>
8 changes: 6 additions & 2 deletions packages/app/browser/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ window.addEventListener("message", (event) => {

const password = document.getElementById("password") as HTMLInputElement;
const submit = document.getElementById("submit") as HTMLButtonElement;
const form = document.getElementById("login-form") as HTMLFormElement;

if (!submit) {
throw new Error("No submit button found");
}
submit.addEventListener("click", () => {

form.addEventListener("submit", (e) => {
e.preventDefault();
document.cookie = `password=${password.value}`;
location.reload();
});
Expand All @@ -38,4 +42,4 @@ const errorDisplay = document.getElementById("error-display") as HTMLDivElement;

if (document.referrer === document.location.href && matches) {
errorDisplay.innerText = "Password is incorrect!";
}
}