feat: restructure org pages based on permission levels (#21611)

This commit is contained in:
Benny Joo authored and GitHub committed 2025-06-13 10:42:04 +01:00
1 parent ba8a71bf3a
commit b931d3ee13
25 files changed
+88 -9

No files matched your search

@@ -0,0 +1,5 @@
import BillingPage, { generateMetadata } from "../../../billing/page";
export { generateMetadata };
export default BillingPage;
@@ -0,0 +1,20 @@
import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
const OrgAdminOnlyLayout = async ({ children }: { children: React.ReactNode }) => {
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
const isOrgAdminOrOwner = checkAdminOrOwner(session?.user?.org?.role);
if (!isOrgAdminOrOwner) {
return redirect("/settings/organizations/profile");
}
return children;
};
export default OrgAdminOnlyLayout;
@@ -1,5 +0,0 @@
import BillingPage, { generateMetadata } from "../../billing/page";
export { generateMetadata };
export default BillingPage;
@@ -0,0 +1,20 @@
import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
const SettingsOrganizationsLayout = async ({ children }: { children: React.ReactNode }) => {
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
const orgExists =
session?.user?.org || session?.user?.profile?.organizationId || session?.user?.profile?.organization;
if (!orgExists) {
return redirect("/settings/my-account/profile");
}
return children;
};
export default SettingsOrganizationsLayout;
@@ -0,0 +1,20 @@
import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import { checkAdminOrOwner } from "@calcom/features/auth/lib/checkAdminOrOwner";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
const OrgAdminOnlyLayout = async ({ children }: { children: React.ReactNode }) => {
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
const isOrgAdminOrOwner = checkAdminOrOwner(session?.user?.org?.role);
if (!isOrgAdminOrOwner) {
return redirect("/settings/organizations/profile");
}
return children;
};
export default OrgAdminOnlyLayout;
@@ -0,0 +1,19 @@
import { cookies, headers } from "next/headers";
import { redirect } from "next/navigation";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
const SettingsOrganizationsLayout = async ({ children }: { children: React.ReactNode }) => {
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
const orgExists =
session?.user?.org || session?.user?.profile?.organizationId || session?.user?.profile?.organization;
if (!orgExists) {
return redirect("/settings/my-account/profile");
}
return children;
};
export default SettingsOrganizationsLayout;