From 98da6eb8471f06833ad16ca4d2b1fb700f4cb99b Mon Sep 17 00:00:00 2001 From: goodm2ice Date: Mon, 7 Feb 2022 17:36:19 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=83=20?= =?UTF-8?q?=D0=B2=D1=85=D0=BE=D0=B4=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BF=D1=8B=D1=82=D0=BA=D0=B5=20=D0=BE=D1=82=D0=BA=D1=80?= =?UTF-8?q?=D1=8B=D1=82=D1=8C=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D1=83=20=D0=B1=D0=B5=D0=B7=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Private/PrivateDefaultRoute.tsx | 3 ++- src/components/Private/PrivateRoute.tsx | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 }) => {