init
This commit is contained in:
25
src/middleware/AuthRoute.js
Normal file
25
src/middleware/AuthRoute.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from "react";
|
||||
import Auth from "./Auth";
|
||||
import { Route, Redirect } from "react-router-dom";
|
||||
|
||||
function AuthRoute({ children, ...rest }) {
|
||||
return (
|
||||
<Route
|
||||
{...rest}
|
||||
render={({ location }) =>
|
||||
Auth.Check(rest.isLogin) ? (
|
||||
children
|
||||
) : (
|
||||
<Redirect
|
||||
to={{
|
||||
pathname: "/login",
|
||||
state: { from: location },
|
||||
}}
|
||||
/>
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default AuthRoute;
|
Reference in New Issue
Block a user