feat: Use Watchlist on sending email verifications (#20114)
This commit is contained in:
1 parent
73e7d6f986
commit
424d94f16d
1 file changed
+16
@@ -7,6 +7,7 @@ import {
|
|||||||
sendChangeOfEmailVerificationLink,
|
sendChangeOfEmailVerificationLink,
|
||||||
} from "@calcom/emails/email-manager";
|
} from "@calcom/emails/email-manager";
|
||||||
import { getFeatureFlag } from "@calcom/features/flags/server/utils";
|
import { getFeatureFlag } from "@calcom/features/flags/server/utils";
|
||||||
|
import { checkIfEmailIsBlockedInWatchlistController } from "@calcom/features/watchlist/operations/check-if-email-in-watchlist.controller";
|
||||||
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
||||||
import { WEBAPP_URL } from "@calcom/lib/constants";
|
import { WEBAPP_URL } from "@calcom/lib/constants";
|
||||||
import logger from "@calcom/lib/logger";
|
import logger from "@calcom/lib/logger";
|
||||||
@@ -40,6 +41,11 @@ export const sendEmailVerification = async ({
|
|||||||
return { ok: true, skipped: true };
|
return { ok: true, skipped: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await checkIfEmailIsBlockedInWatchlistController(email)) {
|
||||||
|
log.warn("Email is blocked - not sending verification email", email);
|
||||||
|
return { ok: false, skipped: false };
|
||||||
|
}
|
||||||
|
|
||||||
if (isPlatform) {
|
if (isPlatform) {
|
||||||
log.warn("Skipping Email verification");
|
log.warn("Skipping Email verification");
|
||||||
return { ok: true, skipped: true };
|
return { ok: true, skipped: true };
|
||||||
@@ -82,6 +88,11 @@ export const sendEmailVerificationByCode = async ({
|
|||||||
username,
|
username,
|
||||||
isVerifyingEmail,
|
isVerifyingEmail,
|
||||||
}: VerifyEmailType) => {
|
}: VerifyEmailType) => {
|
||||||
|
if (await checkIfEmailIsBlockedInWatchlistController(email)) {
|
||||||
|
log.warn("Email is blocked - not sending verification email", email);
|
||||||
|
return { ok: false, skipped: false };
|
||||||
|
}
|
||||||
|
|
||||||
const translation = await getTranslation(language ?? "en", "common");
|
const translation = await getTranslation(language ?? "en", "common");
|
||||||
const secret = createHash("md5")
|
const secret = createHash("md5")
|
||||||
.update(email + process.env.CALENDSO_ENCRYPTION_KEY)
|
.update(email + process.env.CALENDSO_ENCRYPTION_KEY)
|
||||||
@@ -122,6 +133,11 @@ export const sendChangeOfEmailVerification = async ({ user, language }: ChangeOf
|
|||||||
return { ok: true, skipped: true };
|
return { ok: true, skipped: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (await checkIfEmailIsBlockedInWatchlistController(user.emailFrom)) {
|
||||||
|
log.warn("Email is blocked - not sending verification email", user.emailFrom);
|
||||||
|
return { ok: false, skipped: false };
|
||||||
|
}
|
||||||
|
|
||||||
await checkRateLimitAndThrowError({
|
await checkRateLimitAndThrowError({
|
||||||
rateLimitingType: "core",
|
rateLimitingType: "core",
|
||||||
identifier: user.emailFrom,
|
identifier: user.emailFrom,
|
||||||
|
|||||||
Reference in new issue
Block a user