Commit 2f73640f authored by Kim, Subin's avatar Kim, Subin
Browse files

Private Router 수정중

parent 0254fa6b
...@@ -2,28 +2,31 @@ import { Redirect, Route } from "react-router-dom"; ...@@ -2,28 +2,31 @@ import { Redirect, Route } from "react-router-dom";
// import { useAuth } from "../context/auth_context"; // import { useAuth } from "../context/auth_context";
import ErrorPage from "../pages/ErrorPage"; import ErrorPage from "../pages/ErrorPage";
const PrivateRoute = ({ component, ...rest }) => { const PrivateRoute = ({ component: Component, ...rest }) => {
// const { user } = useAuth(); // const { user } = useAuth();
// return ( // return (
// <Route // <Route
// {...rest} // {...rest}
// render={(props) => { // render={(props) => {
// if (user) { // if (user) {
// if (rest.role) { // if (rest.role) {
// if (rest.role === user.role) { // if (rest.role === user.role) {
// return <Component {...props} />; // return <Component {...props} />;
// } else { // } else {
// return <ErrorPage /> // return <ErrorPage />
// } // }
// } else { // } else {
// return <Component {...props} /> // return <Component {...props} />
// } // }
// } else { // } else {
// return <Redirect to="/login" />; // return <Redirect to="/login" />;
// } // }
// }} // }}
// /> // />
// ); // );
return (
<Route {...rest} render={(props) => <Component {...props} />} />
)
}; };
export default PrivateRoute; export default PrivateRoute;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment