fix bug security
This commit is contained in:
+2
-1
@@ -15,6 +15,7 @@ import { getRefreshToken, removeRefreshToken, removeToken, setRefreshToken, setT
|
|||||||
import { refreshToken } from './pages/auth/service/Service';
|
import { refreshToken } from './pages/auth/service/Service';
|
||||||
import BuySpace from './shared/components/BuySpace'
|
import BuySpace from './shared/components/BuySpace'
|
||||||
import useConvertNumbers from './hooks/useConvertNumbers'
|
import useConvertNumbers from './hooks/useConvertNumbers'
|
||||||
|
import CheckWorkSpace from './components/CheckWorkSpace'
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
@@ -102,7 +103,7 @@ const App: FC = () => {
|
|||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<I18nextProvider i18n={i18next}>
|
<I18nextProvider i18n={i18next}>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
|
<CheckWorkSpace />
|
||||||
<Main />
|
<Main />
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
<BuySpace />
|
<BuySpace />
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { FC, useEffect } from 'react'
|
||||||
|
import { useWorkspaces } from '@/pages/home/hooks/useHomeData'
|
||||||
|
import { workspaceItem } from '@/pages/home/types/HomeTypes'
|
||||||
|
|
||||||
|
const CheckWorkSpace: FC = () => {
|
||||||
|
|
||||||
|
const getWorkspaces = useWorkspaces()
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (getWorkspaces.data?.data?.workspaces) {
|
||||||
|
const workspaceId = localStorage.getItem(import.meta.env.VITE_WORKSPACE_ID)
|
||||||
|
const workspace = getWorkspaces.data?.data?.workspaces.find((item: workspaceItem) => item.id === workspaceId)
|
||||||
|
if (!workspace) {
|
||||||
|
localStorage.setItem(import.meta.env.VITE_WORKSPACE_ID, getWorkspaces.data?.data?.workspaces[0].id)
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [getWorkspaces])
|
||||||
|
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CheckWorkSpace
|
||||||
Reference in New Issue
Block a user