Skip to content

Commit

Permalink
Add error message for incorrect password. Fix issue #55 (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDesantis authored and kylecarbs committed Mar 12, 2019
1 parent 7cc7aa5 commit 0efae1f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 14 deletions.
27 changes: 13 additions & 14 deletions packages/app/browser/src/app.html
Expand Up @@ -8,21 +8,20 @@

<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 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>
</body>

Expand Down
13 changes: 13 additions & 0 deletions packages/app/browser/src/app.scss
Expand Up @@ -106,3 +106,16 @@ body {

// transition: 500ms opacity ease;
}

#error-display {
box-sizing: border-box;
color: #bb2d0f;
font-size: 14px;
font-weight: 400;
letter-spacing: 0.3px;
line-height: 12px;
padding: 8px;
padding-bottom: 0;
padding-top: 20px;
text-align: center;
}
11 changes: 11 additions & 0 deletions packages/app/browser/src/app.ts
Expand Up @@ -28,3 +28,14 @@ submit.addEventListener("click", () => {
document.cookie = `password=${password.value}`;
location.reload();
});

/**
* Notify user on load of page if previous password was unsuccessful
*/
const reg = new RegExp(`password=(\\w+);?`);
const matches = document.cookie.match(reg);
const errorDisplay = document.getElementById("error-display") as HTMLDivElement;

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

0 comments on commit 0efae1f

Please sign in to comment.