Added redirect on unauthorized route BOD-162

This commit is contained in:
Patrick Fic
2020-07-20 14:00:17 -07:00
parent d2aa72f5d9
commit 74aca37ee2
4 changed files with 21 additions and 37 deletions

View File

@@ -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}`} />
)
}
/>