Commit a4507148 authored by Omar Luna Hernández's avatar Omar Luna Hernández
Browse files

Se crea una ruta protegida generica

parent e3f2d36b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
import { Navigate, Outlet } from "react-router-dom";
import { useAuth } from "../context/auth_context";

interface ProtectedRouteProps {
    allowedRoles?: string[];
}

export const ProtectedRoute = ({allowedRoles}: ProtectedRouteProps) => {
    const {user} = useAuth();
    if(!user){
        return <Navigate to="/login" replace={true}/>;
    }

    return <Outlet/>;
}
 No newline at end of file