fix: Conditional email verification not working in some cases if verifyUserEmails, preventLoginWithUnverifiedEmail set to functions (#8838)

This commit is contained in:
Manuel
2023-12-26 21:01:27 +01:00
committed by GitHub
parent f9dde4a9f8
commit 8e7a6b1480
5 changed files with 62 additions and 37 deletions

View File

@@ -36,11 +36,10 @@ export class UserController extends AdaptableController {
}
async setEmailVerifyToken(user, req, storage = {}) {
let shouldSendEmail = this.shouldVerifyEmails;
if (typeof shouldSendEmail === 'function') {
const response = await Promise.resolve(shouldSendEmail(req));
shouldSendEmail = response !== false;
}
const shouldSendEmail =
this.shouldVerifyEmails === true ||
(typeof this.shouldVerifyEmails === 'function' &&
(await Promise.resolve(this.shouldVerifyEmails(req))) === true);
if (!shouldSendEmail) {
return false;
}