Error message if login failed
This commit is contained in:
parent
aa88b397d8
commit
1b37c6e755
|
@ -1,12 +1,12 @@
|
||||||
extends ../../../templates/base.pug
|
extends ../../../templates/base.pug
|
||||||
|
|
||||||
block content
|
block content
|
||||||
if loginFailed
|
|
||||||
.alert
|
|
||||||
| Username or password incorrect. Please try again.
|
|
||||||
.row
|
.row
|
||||||
.col
|
.col
|
||||||
.col
|
.col
|
||||||
|
if loginFailed
|
||||||
|
.alert.alert-danger
|
||||||
|
| Username or password incorrect. Please try again.
|
||||||
form(method="POST", action=getUrl("loginTarget"))
|
form(method="POST", action=getUrl("loginTarget"))
|
||||||
.form-group
|
.form-group
|
||||||
input.form-control(type="text", name="username", placeholder="Username", autofocus)
|
input.form-control(type="text", name="username", placeholder="Username", autofocus)
|
||||||
|
|
|
@ -19,6 +19,11 @@ module.exports.redirectIfNotLogged = function(redirectionPage, toDecorate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.login = function(req, res, render) {
|
module.exports.login = function(req, res, render) {
|
||||||
|
if (req.session.loginFailed !== undefined) {
|
||||||
|
res.locals.loginFailed = req.session.loginFailed;
|
||||||
|
req.session.loginFailed = undefined;
|
||||||
|
req.session.save();
|
||||||
|
}
|
||||||
render('login.pug');
|
render('login.pug');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +51,8 @@ module.exports.loginTarget = function(req, res, render) {
|
||||||
|
|
||||||
res.redirect(getUrl(redirection));
|
res.redirect(getUrl(redirection));
|
||||||
} else {
|
} else {
|
||||||
|
req.session.loginFailed = true;
|
||||||
|
req.session.save();
|
||||||
res.redirect(getUrl('login'));
|
res.redirect(getUrl('login'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ html
|
||||||
| Log out
|
| Log out
|
||||||
.container
|
.container
|
||||||
block content
|
block content
|
||||||
|
|
||||||
script(src='/static/bootstrap/js/jquery.min.js')
|
script(src='/static/bootstrap/js/jquery.min.js')
|
||||||
script(src='/static/bootstrap/js/popper.min.js')
|
script(src='/static/bootstrap/js/popper.min.js')
|
||||||
script(src='/static/bootstrap/js/bootstrap.min.js')
|
script(src='/static/bootstrap/js/bootstrap.min.js')
|
||||||
|
|
Loading…
Reference in New Issue