website refactor
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import { headers } from 'next/headers';
|
||||
import { createRouteGuard } from '@/lib/auth/createRouteGuard';
|
||||
|
||||
interface OnboardingLayoutProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
@@ -8,19 +5,22 @@ interface OnboardingLayoutProps {
|
||||
/**
|
||||
* Onboarding Layout
|
||||
*
|
||||
* Provides authentication protection for the onboarding flow.
|
||||
* Uses RouteGuard to enforce access control server-side.
|
||||
* Provides basic layout structure for onboarding pages.
|
||||
* Authentication is handled at the layout boundary.
|
||||
*/
|
||||
import { headers } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { createRouteGuard } from '@/lib/auth/createRouteGuard';
|
||||
|
||||
export default async function OnboardingLayout({ children }: OnboardingLayoutProps) {
|
||||
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 <>{children}</>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user