auth: add logs when auth fails or succeeds

This commit is contained in:
Girish Ramakrishnan
2025-07-11 17:59:00 +02:00
parent a470b2cd4e
commit 22e23e1e65
8 changed files with 70 additions and 38 deletions

View File

@@ -59,7 +59,7 @@ async function userAuthInternal(appId, req, res, next) {
} else if (commonName.indexOf('@') !== -1) { // if mail is specified, enforce mail check
verifyFunc = users.verifyWithEmail;
} else if (commonName.indexOf('uid-') === 0) {
verifyFunc = users.verify;
verifyFunc = users.verifyWithId;
} else {
verifyFunc = users.verifyWithUsername;
}
@@ -458,13 +458,13 @@ async function verifyMailboxPassword(mailbox, password) {
assert.strictEqual(typeof password, 'string');
if (mailbox.ownerType === mail.OWNERTYPE_USER) {
return await users.verify(mailbox.ownerId, password, users.AP_MAIL /* identifier */, { skipTotpCheck: true });
return await users.verifyWithId(mailbox.ownerId, password, users.AP_MAIL /* identifier */, { skipTotpCheck: true });
} else if (mailbox.ownerType === mail.OWNERTYPE_GROUP) {
const userIds = await groups.getMemberIds(mailbox.ownerId);
let verifiedUser = null;
for (const userId of userIds) {
const [error, result] = await safe(users.verify(userId, password, users.AP_MAIL /* identifier */, { skipTotpCheck: true }));
const [error, result] = await safe(users.verifyWithId(userId, password, users.AP_MAIL /* identifier */, { skipTotpCheck: true }));
if (error) continue; // try the next user
verifiedUser = result;
break; // found a matching validated user