diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/layouts/header/Headers.js b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/layouts/header/Headers.js index b8d88f4da7..d2e1c92333 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/layouts/header/Headers.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/components/layouts/header/Headers.js @@ -34,10 +34,10 @@ export default function Header() { [], ); - const handleLogOut = async () => { - storeAccessToken(null) - resetAll(); + const handleLogOut = async () => { api.logout().then(res => { + resetAll(); + storeAccessToken(null) if(res.logoutUrl){ window.location.href = res.logoutUrl } else { diff --git a/apps/dashboard/web/polaris_web/web/src/apps/main/App.js b/apps/dashboard/web/polaris_web/web/src/apps/main/App.js index 0550910887..d5fefd327e 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/main/App.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/main/App.js @@ -292,7 +292,7 @@ const router = createBrowserRouter([ }, { path: "/", - element: , + element: , }, { path: "/signup", diff --git a/apps/dashboard/web/polaris_web/web/src/apps/main/TokenValidator.jsx b/apps/dashboard/web/polaris_web/web/src/apps/main/TokenValidator.jsx new file mode 100644 index 0000000000..85508d0576 --- /dev/null +++ b/apps/dashboard/web/polaris_web/web/src/apps/main/TokenValidator.jsx @@ -0,0 +1,23 @@ +import React from 'react' +import { useEffect } from 'react' +import { useNavigate } from 'react-router-dom' +import PersistStore from './PersistStore' + +function TokenValidator() { + + let navigate = useNavigate() + const accessToken = PersistStore(state => state.accessToken) + useEffect(() => { + console.log(accessToken) + if (accessToken === null || accessToken === '') { + navigate('/login') + } else { + navigate('/dashboard/observe/inventory') + } + },[accessToken]) + return ( + <> + ) +} + +export default TokenValidator \ No newline at end of file