website refactor
This commit is contained in:
@@ -1,26 +1,22 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { headers } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import ProfileLayoutShell from '@/components/profile/ProfileLayoutShell';
|
||||
import { createRouteGuard } from '@/lib/auth/createRouteGuard';
|
||||
|
||||
interface ProfileLayoutProps {
|
||||
children: React.ReactNode;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile Layout
|
||||
*
|
||||
* Provides authentication protection for all profile-related routes.
|
||||
* Uses RouteGuard to enforce access control server-side.
|
||||
*/
|
||||
export default async function ProfileLayout({ children }: ProfileLayoutProps) {
|
||||
const headerStore = await headers();
|
||||
const pathname = headerStore.get('x-pathname') || '/';
|
||||
|
||||
|
||||
const guard = createRouteGuard();
|
||||
await guard.enforce({ pathname });
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-deep-graphite">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
const result = await guard.enforce({ pathname });
|
||||
if (result.type === 'redirect') {
|
||||
redirect(result.to);
|
||||
}
|
||||
|
||||
return <ProfileLayoutShell>{children}</ProfileLayoutShell>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user