Skip to content

Commit b306e62

Browse files
MichaelDesantiskylecarbs
authored andcommitted
Add error message for incorrect password. Fix issue #55 (#201)
1 parent bf80c22 commit b306e62

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

packages/app/browser/src/app.html

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
88

99
<body>
1010
<div class="login">
11-
<div class="back">
12-
<- Back </div>
13-
<h4 class="title">code-server</h4>
14-
<h2 class="subtitle">
15-
Enter server password
16-
</h2>
17-
<div class="mdc-text-field">
18-
<input type="password" id="password" class="mdc-text-field__input" required>
19-
<label class="mdc-floating-label" for="password">Password</label>
20-
<div class="mdc-line-ripple"></div>
21-
</div>
22-
<button id="submit" class="mdc-button mdc-button--unelevated">
23-
<span class="mdc-button__label">Enter IDE</span>
24-
</button>
11+
<div class="back"> <- Back </div>
12+
<h4 class="title">code-server</h4>
13+
<h2 class="subtitle">
14+
Enter server password
15+
</h2>
16+
<div class="mdc-text-field">
17+
<input type="password" id="password" class="mdc-text-field__input" required>
18+
<label class="mdc-floating-label" for="password">Password</label>
19+
<div class="mdc-line-ripple"></div>
2520
</div>
21+
<button id="submit" class="mdc-button mdc-button--unelevated">
22+
<span class="mdc-button__label">Enter IDE</span>
23+
</button>
24+
<div id="error-display"></div>
2625
</div>
2726
</body>
2827

packages/app/browser/src/app.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,16 @@ body {
106106

107107
// transition: 500ms opacity ease;
108108
}
109+
110+
#error-display {
111+
box-sizing: border-box;
112+
color: #bb2d0f;
113+
font-size: 14px;
114+
font-weight: 400;
115+
letter-spacing: 0.3px;
116+
line-height: 12px;
117+
padding: 8px;
118+
padding-bottom: 0;
119+
padding-top: 20px;
120+
text-align: center;
121+
}

packages/app/browser/src/app.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,14 @@ submit.addEventListener("click", () => {
2828
document.cookie = `password=${password.value}`;
2929
location.reload();
3030
});
31+
32+
/**
33+
* Notify user on load of page if previous password was unsuccessful
34+
*/
35+
const reg = new RegExp(`password=(\\w+);?`);
36+
const matches = document.cookie.match(reg);
37+
const errorDisplay = document.getElementById("error-display") as HTMLDivElement;
38+
39+
if (document.referrer === document.location.href && matches) {
40+
errorDisplay.innerText = "Password is incorrect!";
41+
}

0 commit comments

Comments
 (0)