diff --git a/packages/web/src/app/[domain]/layout.tsx b/packages/web/src/app/[domain]/layout.tsx index f2085757a..2879361b6 100644 --- a/packages/web/src/app/[domain]/layout.tsx +++ b/packages/web/src/app/[domain]/layout.tsx @@ -63,9 +63,15 @@ export default async function Layout(props: LayoutProps) { return status; })(); + // Hoist membership so it's available for the billing owner check below (#815) + let membership: Awaited>> = null; + // If the user is authenticated, we must check if they're a member of the org if (session) { - const membership = await prisma.userToOrg.findUnique({ + membership = await prisma.userToOrg.findUnique({ where: { orgId_userId: { orgId: org.id, @@ -171,11 +177,28 @@ export default async function Layout(props: LayoutProps) { (subscription.status !== "active" && subscription.status !== "trialing") ) ) { - return ( - - {children} - - ) + // Only redirect org owners to the upgrade page. + // Non-owners see a message to contact their org owner (#815). + if (membership?.role === 'OWNER') { + return ( + + {children} + + ) + } else { + return ( +
+ +
+

Subscription Expired

+

+ Your organization's subscription has expired or is inactive. + Please contact your organization owner to renew the subscription. +

+
+
+ ) + } } }