From 0efae1fcb674f6e4c6be9c6e71cc83a5001eeb56 Mon Sep 17 00:00:00 2001 From: Michael Desantis Date: Tue, 12 Mar 2019 18:19:32 -0500 Subject: [PATCH] Add error message for incorrect password. Fix issue #55 (#201) --- packages/app/browser/src/app.html | 27 +++++++++++++-------------- packages/app/browser/src/app.scss | 13 +++++++++++++ packages/app/browser/src/app.ts | 11 +++++++++++ 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/packages/app/browser/src/app.html b/packages/app/browser/src/app.html index e5e02993..99e23733 100644 --- a/packages/app/browser/src/app.html +++ b/packages/app/browser/src/app.html @@ -8,21 +8,20 @@
-
- <- Back
-

code-server

-

- Enter server password -

-
- - -
-
- +
<- Back
+

code-server

+

+ Enter server password +

+
+ + +
+ +
diff --git a/packages/app/browser/src/app.scss b/packages/app/browser/src/app.scss index 376befb9..8b504328 100644 --- a/packages/app/browser/src/app.scss +++ b/packages/app/browser/src/app.scss @@ -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; +} diff --git a/packages/app/browser/src/app.ts b/packages/app/browser/src/app.ts index ecb1a0f3..ddb35e7e 100644 --- a/packages/app/browser/src/app.ts +++ b/packages/app/browser/src/app.ts @@ -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!"; +} \ No newline at end of file