diff --git a/src/components/Private/PrivateDefaultRoute.tsx b/src/components/Private/PrivateDefaultRoute.tsx index 5e8ddbc..6e9ef08 100644 --- a/src/components/Private/PrivateDefaultRoute.tsx +++ b/src/components/Private/PrivateDefaultRoute.tsx @@ -1,6 +1,7 @@ import { memo } from 'react' import { Redirect, Route, RouteProps } from 'react-router-dom' +import { getUserId } from '@utils/storage' import { isURLAvailable } from '@utils/permissions' export type PrivateDefaultRouteProps = RouteProps & { @@ -10,7 +11,7 @@ export type PrivateDefaultRouteProps = RouteProps & { export const PrivateDefaultRoute = memo(({ elseRedirect, urls, ...other }) => ( - isURLAvailable(url)) ?? elseRedirect ?? '/access_denied' }} /> + isURLAvailable(url)) ?? elseRedirect ?? (getUserId() ? '/access_denied' : '/login') }} /> )) diff --git a/src/components/Private/PrivateRoute.tsx b/src/components/Private/PrivateRoute.tsx index 158f1b8..366aaa4 100644 --- a/src/components/Private/PrivateRoute.tsx +++ b/src/components/Private/PrivateRoute.tsx @@ -3,6 +3,7 @@ import { memo, ReactNode } from 'react' import { Redirect, Route, RouteProps } from 'react-router-dom' import { join } from 'path' +import { getUserId } from '@utils/storage' import { isURLAvailable } from '@utils/permissions' export type PrivateRouteProps = RouteProps & { @@ -13,7 +14,7 @@ export type PrivateRouteProps = RouteProps & { } export const defaultRedirect = (location?: Location) => ( - + ) export const PrivateRoute = memo(({ root = '', path, component, children, redirect = defaultRedirect, ...other }) => {