Added redirect on unauthorized route BOD-162
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import React from "react";
|
||||
import { Route, Redirect } from "react-router-dom";
|
||||
import { Route, Redirect, useLocation } from "react-router-dom";
|
||||
export default ({ component: Component, isAuthorized, ...rest }) => {
|
||||
const location = useLocation();
|
||||
|
||||
return (
|
||||
<Route
|
||||
{...rest}
|
||||
@@ -8,7 +10,7 @@ export default ({ component: Component, isAuthorized, ...rest }) => {
|
||||
isAuthorized === true ? (
|
||||
<Component {...props} />
|
||||
) : (
|
||||
<Redirect to="/signin" />
|
||||
<Redirect to={`/signin?redirect=${location.pathname}`} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user