fix: disable emails for platform (#15089)

* disable emails for platform

* check for if user is platform and skip verification accordingly

* skip isPlatform check for verify email in create org handler

* use if instead of &&

---------

Co-authored-by: Morgan <[email protected]>
This commit is contained in:
Rajiv SahalandMorgan authored and GitHub committed 2024-05-17 18:07:04 +05:30
1 parent e723b989a8
commit a559daa076
2 files changed
+34 -22

No files matched your search

@@ -20,6 +20,7 @@ interface VerifyEmailType {
email: string;
language?: string;
secondaryEmailId?: number;
isPlatform?: boolean;
}
export const sendEmailVerification = async ({
@@ -27,6 +28,7 @@ export const sendEmailVerification = async ({
language,
username,
secondaryEmailId,
isPlatform = false,
}: VerifyEmailType) => {
const token = randomBytes(32).toString("hex");
const translation = await getTranslation(language ?? "en", "common");
@@ -37,6 +39,11 @@ export const sendEmailVerification = async ({
return { ok: true, skipped: true };
}
if (isPlatform) {
log.warn("Skipping Email verification");
return { ok: true, skipped: true };
}
await checkRateLimitAndThrowError({
rateLimitingType: "core",
identifier: email,