Uecko_ERP/modules/auth/src/web/components/auth-guard.tsx

16 lines
343 B
TypeScript
Raw Normal View History

2025-05-27 17:47:03 +00:00
import { JSX } from "react";
import { Navigate } from "react-router-dom";
/**
* Protege una ruta para usuarios autenticados.
*/
export const AuthGuard = ({ children }: { children: JSX.Element }) => {
const { isAuthenticated } = useAuth();
if (!isAuthenticated) {
return <Navigate to='/login' replace />;
}
return children;
};