change back fetch subscription to not require org membership

This commit is contained in:
msukkari 2025-02-13 15:36:48 -08:00
parent cf97955b23
commit ea4c29daec

View file

@ -332,9 +332,8 @@ export const redeemInvite = async (invite: Invite, userId: string): Promise<{ su
// Incrememnt the seat count
if (org.stripeCustomerId) {
const subscription = await fetchSubscription(org.domain);
console.log("subscription", subscription)
if (isServiceError(subscription)) {
return orgInvalidSubscription();
throw orgInvalidSubscription();
}
const existingSeatCount = subscription.items.data[0].quantity;
@ -548,11 +547,10 @@ export const getCustomerPortalSessionLink = async (domain: string): Promise<stri
}));
export const fetchSubscription = (domain: string): Promise<any | ServiceError> =>
withAuth((session) =>
withOrgMembership(session, domain, async (orgId) => {
withAuth(async () => {
const org = await prisma.org.findUnique({
where: {
id: orgId,
domain,
},
});
@ -568,7 +566,7 @@ export const fetchSubscription = (domain: string): Promise<any | ServiceError> =
return notFound();
}
return subscriptions.data[0];
}));
});
export const checkIfUserHasOrg = async (userId: string): Promise<boolean | ServiceError> => {
const orgs = await prisma.userToOrg.findMany({