Add error message for incorrect password. Fix issue #55 (#201)

This commit is contained in:
Michael Desantis
2019-03-12 18:19:32 -05:00
committed by Kyle Carberry
parent 7cc7aa51aa
commit 0efae1fcb6
3 changed files with 37 additions and 14 deletions

View File

@@ -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!";
}