Files
hanarang-dashboard/frontend/components/common/AppShell.tsx
나랑이 176cb51f8a feat(sprint-010): API Key 완전 제거 + JWT 전용 정리 + 죽은 코드 청소
TASK-036: admin/layout.tsx API Key UI 완전 제거
TASK-037: adminFetch JWT 전용 단순화 (api key fallback 제거)
TASK-038: ApiKeyStrategy, ApiKeyGuard, CompositeGuard 제거
  - api-key.strategy.ts, api-key.guard.ts 파일 삭제
  - 모든 컨트롤러 @UseGuards JwtGuard로 전환
  - AuthModule에서 ApiKey 관련 providers 제거
TASK-039: PUBLIC_PATHS에서 /register 제거, login FooterLink dead code 제거

테스트 23/23 pass, FE 16 routes build 성공
2026-04-04 17:24:32 +09:00

51 lines
1.3 KiB
TypeScript

'use client';
import React, { useEffect } from 'react';
import { useRouter, usePathname } from 'next/navigation';
import { AuthProvider, useAuth } from '@/lib/AuthContext';
import LayoutShell from './LayoutShell';
const PUBLIC_PATHS = ['/login'];
function AuthGate({ children }: { children: React.ReactNode }) {
const { isAuthenticated, loading } = useAuth();
const router = useRouter();
const pathname = usePathname();
useEffect(() => {
if (loading) return;
const isPublic = PUBLIC_PATHS.includes(pathname);
if (!isAuthenticated && !isPublic) {
router.replace('/login');
}
if (isAuthenticated && isPublic) {
router.replace('/');
}
}, [isAuthenticated, loading, pathname, router]);
if (loading) {
return (
<div style={{
display: 'flex', alignItems: 'center', justifyContent: 'center',
height: '100vh', background: '#151515', color: '#8A8A8A',
fontFamily: 'monospace', fontSize: '12px',
}}>
AUTHENTICATING...
</div>
);
}
const isPublic = PUBLIC_PATHS.includes(pathname);
if (isPublic) return <>{children}</>;
return <LayoutShell>{children}</LayoutShell>;
}
export default function AppShell({ children }: { children: React.ReactNode }) {
return (
<AuthProvider>
<AuthGate>{children}</AuthGate>
</AuthProvider>
);
}