pass onUnauthorized to AuthProvider instead of separate event listener

This commit is contained in:
2026-07-19 03:18:36 +05:30
parent d2347de932
commit 77db5e1f05

View File

@@ -83,15 +83,8 @@ const routerMapping = [
function AppContent() { function AppContent() {
const { authConfig } = useAppContext(); const { authConfig } = useAppContext();
const navigate = useNavigate(); const navigate = useNavigate();
React.useEffect(() => {
const handler = () => navigate("/login");
window.addEventListener("auth:unauthorized", handler);
return () => window.removeEventListener("auth:unauthorized", handler);
}, [navigate]);
return ( return (
<AuthProvider authConfig={authConfig}> <AuthProvider authConfig={authConfig} onUnauthorized={() => navigate("/login")}>
<AppTheme> <AppTheme>
<CssBaseline enableColorScheme /> <CssBaseline enableColorScheme />
<Header routerMapping={routerMapping} /> <Header routerMapping={routerMapping} />