ldap: use proper error message instead of dn
the dn is already in lde_dn field of the error object. lde_message is the message
This commit is contained in:
@@ -298,7 +298,7 @@ async function userAuth(req, res, next) {
|
||||
// extract the common name which might have different attribute names
|
||||
const cnAttributeName = Object.keys(req.dn.rdns[0].attrs)[0];
|
||||
const commonName = req.dn.rdns[0].attrs[cnAttributeName].value;
|
||||
if (!commonName) return next(new ldap.NoSuchObjectError(req.dn.toString()));
|
||||
if (!commonName) return next(new ldap.NoSuchObjectError('Missing CN'));
|
||||
|
||||
const TOTPTOKEN_ATTRIBUTE_NAME = 'totptoken'; // This has to be in-sync with externalldap.js
|
||||
const totpToken = req.dn.rdns[0].attrs[TOTPTOKEN_ATTRIBUTE_NAME] ? req.dn.rdns[0].attrs[TOTPTOKEN_ATTRIBUTE_NAME].value : null;
|
||||
@@ -353,8 +353,8 @@ async function start() {
|
||||
|
||||
const config = await getConfig();
|
||||
|
||||
if (!req.dn.equals(constants.USER_DIRECTORY_LDAP_DN)) return next(new ldap.InvalidCredentialsError(req.dn.toString()));
|
||||
if (req.credentials !== config.secret) return next(new ldap.InvalidCredentialsError(req.dn.toString()));
|
||||
if (!req.dn.equals(constants.USER_DIRECTORY_LDAP_DN)) return next(new ldap.InvalidCredentialsError('Invalid DN'));
|
||||
if (req.credentials !== config.secret) return next(new ldap.InvalidCredentialsError('Invalid Secret'));
|
||||
|
||||
req.user = { user: 'directoryServerAdmin' };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user