fix: enforce SSO in invitation signups (#1258)

This commit is contained in:
Philip Okugbe
2025-06-15 20:25:15 +01:00
committed by GitHub
parent 1c674efddd
commit 44445fbf46
7 changed files with 78 additions and 47 deletions

View File

@ -6,3 +6,16 @@ export function validateSsoEnforcement(workspace: Workspace) {
throw new BadRequestException('This workspace has enforced SSO login.');
}
}
export function validateAllowedEmail(userEmail: string, workspace: Workspace) {
const emailParts = userEmail.split('@');
const emailDomain = emailParts[1].toLowerCase();
if (
workspace.emailDomains?.length > 0 &&
!workspace.emailDomains.includes(emailDomain)
) {
throw new BadRequestException(
`The email domain "${emailDomain}" is not approved for this workspace.`,
);
}
}