mirror of
https://github.com/docmost/docmost.git
synced 2025-11-20 06:51:10 +10:00
22 lines
698 B
TypeScript
22 lines
698 B
TypeScript
import { BadRequestException } from '@nestjs/common';
|
|
import { Workspace } from '@docmost/db/types/entity.types';
|
|
|
|
export function validateSsoEnforcement(workspace: Workspace) {
|
|
if (workspace.enforceSso) {
|
|
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.`,
|
|
);
|
|
}
|
|
}
|