dont early return on multi org

This commit is contained in:
miloschwartz
2026-05-02 20:37:56 -07:00
parent 279211142d
commit 3694f43ae8

View File

@@ -336,31 +336,22 @@ export async function validateOidcCallback(
.innerJoin(orgs, eq(orgs.orgId, idpOrg.orgId)); .innerJoin(orgs, eq(orgs.orgId, idpOrg.orgId));
allOrgs = idpOrgs.map((o) => o.orgs); allOrgs = idpOrgs.map((o) => o.orgs);
// TODO: when there are multiple orgs we need to do this better!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1 for (const org of allOrgs) {
if (allOrgs.length > 1) {
// for some reason there is more than one org
logger.error(
"More than one organization linked to this IdP. This should not happen with auto-provisioning enabled."
);
return next(
createHttpError(
HttpCode.INTERNAL_SERVER_ERROR,
"Multiple organizations linked to this IdP. Please contact support."
)
);
}
const subscribed = await isSubscribed( const subscribed = await isSubscribed(
allOrgs[0].orgId, org.orgId,
tierMatrix.autoProvisioning tierMatrix.autoProvisioning
); );
if (!subscribed) { if (!subscribed) {
return next( // filter out the org
createHttpError( allOrgs = allOrgs.filter((o) => o.orgId !== org.orgId);
HttpCode.FORBIDDEN,
"This organization's current plan does not support this feature." // return next(
) // createHttpError(
); // HttpCode.FORBIDDEN,
// "This organization's current plan does not support this feature."
// )
// );
}
} }
} else { } else {
allOrgs = await db.select().from(orgs); allOrgs = await db.select().from(orgs);