Add support for LDAP cn=...+totptoken=.. support
This commit is contained in:
@@ -43,8 +43,13 @@ async function passwordAuth(req, res, next) {
|
||||
if (!user.ghost && !user.appPassword && user.twoFactorAuthenticationEnabled) {
|
||||
if (!totpToken) return next(new HttpError(401, 'A totpToken must be provided'));
|
||||
|
||||
const verified = speakeasy.totp.verify({ secret: user.twoFactorAuthenticationSecret, encoding: 'base32', token: totpToken, window: 2 });
|
||||
if (!verified) return next(new HttpError(401, 'Invalid totpToken'));
|
||||
if (user.source === 'ldap') {
|
||||
const [error] = await safe(externalLdap.verifyPasswordAndTotpToken(user, password, totpToken));
|
||||
if (error) return next(new HttpError(401, 'Invalid totpToken'));
|
||||
} else {
|
||||
const verified = speakeasy.totp.verify({ secret: user.twoFactorAuthenticationSecret, encoding: 'base32', token: totpToken, window: 2 });
|
||||
if (!verified) return next(new HttpError(401, 'Invalid totpToken'));
|
||||
}
|
||||
}
|
||||
|
||||
req.user = user;
|
||||
|
||||
Reference in New Issue
Block a user