LDAP login improvements

- return bad request if no username or password given
- return to referer url on auth success
- flash error message on auth failure
This commit is contained in:
alecdwm 2016-12-14 12:40:54 +01:00
parent 3007163799
commit fc8d709afb
1 changed files with 9 additions and 3 deletions

12
app.js
View File

@ -382,9 +382,15 @@ if (config.google) {
}
// ldap auth
if (config.ldap) {
app.post('/auth/ldap', urlencodedParser,
passport.authenticate('ldapauth', { successRedirect: '/' })
);
app.post('/auth/ldap', urlencodedParser, function (req, res, next) {
if (!req.body.username || !req.body.password) return response.errorBadRequest(res);
setReturnToFromReferer(req);
passport.authenticate('ldapauth', {
successReturnToOrRedirect: config.serverurl + '/',
failureRedirect: config.serverurl + '/',
failureFlash: true
})(req, res, next);
});
}
// email auth
if (config.email) {