misc: added license checks for oidc sso

This commit is contained in:
Sheen Capadngan
2024-06-18 01:11:57 +08:00
parent 2c237ee277
commit d79ffbe37e
5 changed files with 49 additions and 17 deletions
@@ -196,9 +196,6 @@ export const oidcConfigServiceFactory = ({
}
);
// TODO: Sheen update oidc config
// await samlConfigDAL.update({ orgId }, { lastUsed: new Date() });
if (user.email && !user.isEmailVerified) {
const token = await tokenService.createTokenForUser({
type: TokenType.TOKEN_EMAIL_VERIFICATION,
@@ -315,12 +312,20 @@ export const oidcConfigServiceFactory = ({
const org = await orgDAL.findOne({
slug: orgSlug
});
if (!org) {
throw new BadRequestError({
message: "Organization not found"
});
}
const plan = await licenseService.getPlan(org.id);
if (!plan.oidcSSO)
throw new BadRequestError({
message:
"Failed to update OIDC SSO configuration due to plan restriction. Upgrade plan to update SSO configuration."
});
const { permission } = await permissionService.getOrgPermission(
actor,
actorId,
@@ -396,6 +401,13 @@ export const oidcConfigServiceFactory = ({
});
}
const plan = await licenseService.getPlan(org.id);
if (!plan.oidcSSO)
throw new BadRequestError({
message:
"Failed to create OIDC SSO configuration due to plan restriction. Upgrade plan to update SSO configuration."
});
const { permission } = await permissionService.getOrgPermission(
actor,
actorId,