TP-17651 | Auth Changes

This commit is contained in:
yashmantri
2023-05-07 14:52:30 +05:30
parent 91c719c9ed
commit d079fe34c2
3 changed files with 10 additions and 6 deletions

View File

@@ -53,7 +53,7 @@ const App = () => {
return (
<>
{/* {isAuthenticated ? ( */}
{isAuthenticated ? (
<Suspense fallback={<div />}>
<BrowserRouter>
<LeftSideBar>
@@ -65,9 +65,9 @@ const App = () => {
</LeftSideBar>
</BrowserRouter>
</Suspense>
{/* ) : (
) : (
<h2>You need the access to visit this site</h2>
)} */}
)}
</>
);
};

View File

@@ -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<LeftNavProps> = ({ 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<LeftNavProps> = ({ children }) => {
options: [
{
label: 'Logout',
handleClick: () => {},
handleClick: logout,
},
],
};

View File

@@ -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();
};