Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit cbc7a17

Browse files
✨ Check if new email is disposable
1 parent 163e54a commit cbc7a17

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/rest/email.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { trackEvent } from "../helpers/tracking";
1616
import { EventType, UserScopes } from "../interfaces/enum";
1717
import { KeyValue, Locals } from "../interfaces/general";
1818
import { Email } from "../interfaces/tables/emails";
19+
import { ALLOW_DISPOSABLE_EMAILS } from "../config";
20+
import { checkIfDisposableEmail } from "@staart/disposable-email";
1921

2022
export const getAllEmailsForUser = async (
2123
tokenUserId: string,
@@ -69,6 +71,7 @@ export const addEmailToUserForUser = async (
6971
) => {
7072
if (!(await can(tokenUserId, UserScopes.CREATE_USER_EMAILS, "user", userId)))
7173
throw new Error(INSUFFICIENT_PERMISSION);
74+
if (!ALLOW_DISPOSABLE_EMAILS) checkIfDisposableEmail(email);
7275
await checkIfNewEmail(email);
7376
await createEmail({ email, userId });
7477
trackEvent(

0 commit comments

Comments
 (0)