centralize email parsing logic

This commit is contained in:
Tom Moor
2024-07-07 10:54:19 -04:00
parent c484d1defe
commit bdcde1aa53
8 changed files with 52 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import { InferCreationAttributes } from "sequelize";
import { UserRole } from "@shared/types";
import { parseEmail } from "@shared/utils/email";
import InviteAcceptedEmail from "@server/emails/templates/InviteAcceptedEmail";
import {
DomainNotAllowedError,
@@ -226,7 +227,7 @@ export default async function userProvisioner({
// If the team settings do not allow this domain,
// throw an error and fail user creation.
const domain = email.split("@")[1];
const { domain } = parseEmail(email);
if (team && !(await team.isDomainAllowed(domain))) {
throw DomainNotAllowedError();
}