clean routes
This commit is contained in:
@@ -1,24 +1,26 @@
|
||||
'use client';
|
||||
|
||||
import { AuthGuard } from '@/lib/gateways/AuthGuard';
|
||||
import { ReactNode } from 'react';
|
||||
import { headers } from 'next/headers';
|
||||
import { createRouteGuard } from '@/lib/auth/createRouteGuard';
|
||||
|
||||
interface ProfileLayoutProps {
|
||||
children: ReactNode;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile Layout
|
||||
*
|
||||
*
|
||||
* Provides authentication protection for all profile-related routes.
|
||||
* Wraps children with AuthGuard to ensure only authenticated users can access.
|
||||
* Uses RouteGuard to enforce access control server-side.
|
||||
*/
|
||||
export default function ProfileLayout({ children }: ProfileLayoutProps) {
|
||||
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 (
|
||||
<AuthGuard redirectPath="/auth/login">
|
||||
<div className="min-h-screen bg-deep-graphite">
|
||||
{children}
|
||||
</div>
|
||||
</AuthGuard>
|
||||
<div className="min-h-screen bg-deep-graphite">
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user