Skip to content
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

Add "Incorrect username or password" message #272

Merged
merged 1 commit into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions public/css/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ iframe {
overflow: hidden;
}

#login-fail {
color: red;
display: none;
}

#bottom-text {
text-align: left;
margin: 5px 14px;
Expand Down
2 changes: 1 addition & 1 deletion public/js/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ function responseCallback(response, includedTerms) {
return;
}
if (response.recent.login_fail) {
location.href = '/logout';
location.href = "/logout?fail=1";
}

if (response.classes.length === 0) {
Expand Down
5 changes: 5 additions & 0 deletions public/js/login.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Show "incorrect username or password" on failed login
if ((new URLSearchParams(window.location.search)).get("fail") === "1") {
document.querySelector("#login-fail").style.setProperty("display", "unset");
}

// Remember me - load username from localStorage
window.addEventListener("load", () => {
localStorage.removeItem("password");
Expand Down
3 changes: 3 additions & 0 deletions public/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
<span class="txt1" style="color:#595959">
Aspen credentials or leave blank to import data
</span>
<span id="login-fail" class="txt3">
Incorrect username or password.
</span>
</div>
<!-- Username Input -->
<div class="wrap-input100">
Expand Down
5 changes: 4 additions & 1 deletion serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ app.post('/login', async (req, res) => {

app.get('/logout', async (req, res) => {
req.session.destroy();
res.redirect('/login');
if (req.query.fail === '1')
res.redirect('/login?fail=1');
else
res.redirect('/login');
});


Expand Down