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) { const subscribed = await isSubscribed(
// for some reason there is more than one org org.orgId,
logger.error( tierMatrix.autoProvisioning
"More than one organization linked to this IdP. This should not happen with auto-provisioning enabled."
); );
return next( if (!subscribed) {
createHttpError( // filter out the org
HttpCode.INTERNAL_SERVER_ERROR, allOrgs = allOrgs.filter((o) => o.orgId !== org.orgId);
"Multiple organizations linked to this IdP. Please contact support."
)
);
}
const subscribed = await isSubscribed( // return next(
allOrgs[0].orgId, // createHttpError(
tierMatrix.autoProvisioning // HttpCode.FORBIDDEN,
); // "This organization's current plan does not support this feature."
if (!subscribed) { // )
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);