From d079fe34c2861d21ec58b8182d978c1b3597a548 Mon Sep 17 00:00:00 2001 From: yashmantri Date: Sun, 7 May 2023 14:52:30 +0530 Subject: [PATCH] TP-17651 | Auth Changes --- src/App.tsx | 6 +++--- src/components/LeftSideBar/index.tsx | 5 ++--- src/utils/index.tsx | 5 +++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3e93669..fc45527 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -53,7 +53,7 @@ const App = () => { return ( <> - {/* {isAuthenticated ? ( */} + {isAuthenticated ? ( }> @@ -65,9 +65,9 @@ const App = () => { - {/* ) : ( + ) : (

You need the access to visit this site

- )} */} + )} ); }; diff --git a/src/components/LeftSideBar/index.tsx b/src/components/LeftSideBar/index.tsx index 739a3df..93c81e0 100644 --- a/src/components/LeftSideBar/index.tsx +++ b/src/components/LeftSideBar/index.tsx @@ -4,11 +4,11 @@ import Grid from '@mui/material/Grid'; import Navbar from '@navi/web-ui/lib/components/Navbar'; import { DashboardIcon, FilterIconFilled } from '@navi/web-ui/lib/icons'; import naviLogo from '../../Icons/naviLogoWithIcon.svg'; -// import { logout } from '../../utils/utils'; import { useAppSelector } from '../../redux/hooks'; import './index.scss'; import litmusLogo from '../../Icons/LitmusLogo.svg'; import { ROUTE_MAPPING } from '../../utils/constants'; +import { logout } from '../../utils'; interface LeftNavProps { children: React.ReactNode; @@ -17,7 +17,6 @@ interface LeftNavProps { const LeftSideBar: React.FC = ({ children }) => { const navigate = useNavigate(); const { authData } = useAppSelector((state) => state.authStore); - // const { isFullScreen } = useAppSelector((state) => state.graphStore); const sideBarItems: any[] = [ { @@ -48,7 +47,7 @@ const LeftSideBar: React.FC = ({ children }) => { options: [ { label: 'Logout', - handleClick: () => {}, + handleClick: logout, }, ], }; diff --git a/src/utils/index.tsx b/src/utils/index.tsx index ccd6992..bde4626 100644 --- a/src/utils/index.tsx +++ b/src/utils/index.tsx @@ -433,3 +433,8 @@ export const checkLitmusWritePermission = (permissions: any) => { export const checkLitmusReadPermission = (permissions: any) => { return permissions?.includes('litmus.experiment.READ') || false; }; + +export const logout = () => { + localStorage.removeItem('auth-token'); + window.location.reload(); +};