mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00

* chore: add detailed logs * feat: added a variable to specify which attributes to be stored * chore: Add new optiona variables * refactor: change BIND_DN as an option * chore: revert commits that fail testing * refactor: use ldapid to retrieve users * chore: remove unused variable * chore: reverting unintended changes * fix: return 404 if authentication fails, in accordance with requireLocalAuth. * fix: handling when ldap settings do not exist * chore: remove unnecessary check
22 lines
576 B
JavaScript
22 lines
576 B
JavaScript
const passport = require('passport');
|
|
|
|
const requireLdapAuth = (req, res, next) => {
|
|
passport.authenticate('ldapauth', (err, user, info) => {
|
|
if (err) {
|
|
console.log({
|
|
title: '(requireLdapAuth) Error at passport.authenticate',
|
|
parameters: [{ name: 'error', value: err }],
|
|
});
|
|
return next(err);
|
|
}
|
|
if (!user) {
|
|
console.log({
|
|
title: '(requireLdapAuth) Error: No user',
|
|
});
|
|
return res.status(404).send(info);
|
|
}
|
|
req.user = user;
|
|
next();
|
|
})(req, res, next);
|
|
};
|
|
module.exports = requireLdapAuth;
|