import { useAuth } from "react-oidc-context"; import { Navigate, Outlet, useLocation, useNavigate } from "react-router-dom"; import { t } from "../../lib/i18n"; export default function AuthGuard() { const auth = useAuth(); const location = useLocation(); const navigate = useNavigate(); const searchParams = new URLSearchParams(location.search); const shareToken = searchParams.get("token"); const isPlaywrightBypass = typeof window !== "undefined" && (window.location.hostname === "127.0.0.1" || window.location.hostname === "localhost") && window.localStorage.getItem("playwright_auth_bypass") === "1"; // 공유 토큰이 있는 경우 인증 체크를 건너뜁니다 (Public View) if (shareToken || isPlaywrightBypass) { return ; } if (auth.isLoading || auth.activeNavigator) { return
Loading...
; } if (auth.error) { return
Auth Error: {auth.error.message}
; } if (!auth.isAuthenticated) { const returnTo = `${location.pathname}${location.search}`; return ( ); } // 조직도 앱은 일반 사용자(user)도 볼 수 있어야 하므로 접근 제한을 해제합니다. const isDenied = false; // normalizedRole === "guest"; if (isDenied) { return (

{t("msg.dev.auth.access_denied_title", "접근 권한이 없습니다.")}

{t( "msg.dev.auth.access_denied_description", "조직도를 볼 수 있는 권한이 없습니다.", )}

); } return ; }