From 8fe7c1b9c9cb0d7b15f7a3516e002aa0b6f116a8 Mon Sep 17 00:00:00 2001 From: shivamrawat101192 Date: Wed, 20 Mar 2024 15:55:54 +0530 Subject: [PATCH 1/3] login page redirect fix --- .../src/apps/dashboard/components/layouts/header/Headers.js | 6 +++--- apps/dashboard/web/polaris_web/web/src/apps/main/App.js | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) 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 cc880569f3..f6a8df7ca3 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 @@ -59,6 +59,7 @@ import TestLibrary from "../dashboard/pages/settings/test_library/TestLibrary"; import { useStiggContext } from '@stigg/react-sdk'; import DependencyTable from "../dashboard/pages/testing/DependencyTable/DependencyTable"; import SignupPage from "../signup/pages/SignupPage"; +import TokenValidator from "./TokenValidator"; // if you add a component in a new path, please verify the search implementation in function -> 'getSearchItemsArr' in func.js @@ -290,7 +291,7 @@ const router = createBrowserRouter([ }, { path: "/", - element: , + element: , }, { path: "/signup", From d0b9c09d7cdc2e6876f37af37459c6b61d799dcd Mon Sep 17 00:00:00 2001 From: shivamrawat101192 Date: Wed, 20 Mar 2024 16:02:59 +0530 Subject: [PATCH 2/3] login page redirect fix --- .../web/src/apps/main/TokenValidator.jsx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 apps/dashboard/web/polaris_web/web/src/apps/main/TokenValidator.jsx 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 From 67bddc8b160a6259e1dab09421255eff5dbd3e3b Mon Sep 17 00:00:00 2001 From: notshivansh Date: Wed, 20 Mar 2024 16:16:49 +0530 Subject: [PATCH 3/3] fix paths --- apps/dashboard/web/polaris_web/web/src/apps/main/App.js | 2 ++ 1 file changed, 2 insertions(+) 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 0b14846d72..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 @@ -59,6 +59,8 @@ import TestLibrary from "../dashboard/pages/settings/test_library/TestLibrary"; import { useStiggContext } from '@stigg/react-sdk'; import DependencyTable from "../dashboard/pages/testing/DependencyTable/DependencyTable"; import SignupPage from "../signup/pages/SignupPage"; +import PageCheckInbox from "../signup/pages/PageCheckInbox" +import PageBusinessEmail from "../signup/pages/PageBusinessEmail" // if you add a component in a new path, please verify the search implementation in function -> 'getSearchItemsArr' in func.js