dashboard: ensure you only access what you have access to
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
|
import { notFound } from 'next/navigation';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getCurrentOrganizations,
|
getCurrentOrganizations,
|
||||||
getDashboardsByOrganization,
|
|
||||||
getDashboardsByProjectId,
|
getDashboardsByProjectId,
|
||||||
|
getProjectsByOrganizationSlug,
|
||||||
} from '@openpanel/db';
|
} from '@openpanel/db';
|
||||||
|
|
||||||
import { LayoutSidebar } from './layout-sidebar';
|
import { LayoutSidebar } from './layout-sidebar';
|
||||||
@@ -18,11 +20,20 @@ export default async function AppLayout({
|
|||||||
children,
|
children,
|
||||||
params: { organizationId, projectId },
|
params: { organizationId, projectId },
|
||||||
}: AppLayoutProps) {
|
}: AppLayoutProps) {
|
||||||
const [organizations, dashboards] = await Promise.all([
|
const [organizations, projects, dashboards] = await Promise.all([
|
||||||
getCurrentOrganizations(),
|
getCurrentOrganizations(),
|
||||||
|
getProjectsByOrganizationSlug(organizationId),
|
||||||
getDashboardsByProjectId(projectId),
|
getDashboardsByProjectId(projectId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (!organizations.find((item) => item.slug === organizationId)) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!projects.find((item) => item.id === projectId)) {
|
||||||
|
return notFound();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="dashboard">
|
<div id="dashboard">
|
||||||
<LayoutSidebar
|
<LayoutSidebar
|
||||||
|
|||||||
Reference in New Issue
Block a user