Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0001fe5d59 | |||
| 2ee928a2e3 | |||
| dd581a8cdc |
@@ -16,4 +16,6 @@ REACT_APP_PREVIEW_DOCS_URL=https://preview.keenthemes.com/metronic8/react/docs
|
|||||||
REACT_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
REACT_APP_THEME_API_URL=https://preview.keenthemes.com/theme-api/api
|
||||||
REACT_APP_TERMS_LINK='https://www.float.sg/terms'
|
REACT_APP_TERMS_LINK='https://www.float.sg/terms'
|
||||||
REACT_APP_CONTACT_LINK='https://www.float.sg/contact'
|
REACT_APP_CONTACT_LINK='https://www.float.sg/contact'
|
||||||
REACT_APP_ABOUT_LINK='https://www.float.sg/about'
|
REACT_APP_ABOUT_LINK='https://www.float.sg/about'
|
||||||
|
|
||||||
|
REACT_APP_LOGOUT_SESSION_TIMEOUT=300000
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
Dispatch,
|
Dispatch,
|
||||||
SetStateAction,
|
SetStateAction,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
import {useLocation} from 'react-router-dom'
|
||||||
import {LayoutSplashScreen} from '../../../../_res/layout/core'
|
import {LayoutSplashScreen} from '../../../../_res/layout/core'
|
||||||
import {AuthModel, UserModel} from './_models'
|
import {AuthModel, UserModel} from './_models'
|
||||||
import * as authHelper from './AuthHelpers'
|
import * as authHelper from './AuthHelpers'
|
||||||
@@ -61,6 +62,7 @@ const AuthProvider: FC<WithChildren> = ({children}) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AuthInit: FC<WithChildren> = ({children}) => {
|
const AuthInit: FC<WithChildren> = ({children}) => {
|
||||||
|
const {pathname} = useLocation()
|
||||||
const {auth, logout, setCurrentUser} = useAuth()
|
const {auth, logout, setCurrentUser} = useAuth()
|
||||||
const didRequest = useRef(false)
|
const didRequest = useRef(false)
|
||||||
const [showSplashScreen, setShowSplashScreen] = useState(true)
|
const [showSplashScreen, setShowSplashScreen] = useState(true)
|
||||||
@@ -95,8 +97,17 @@ const AuthInit: FC<WithChildren> = ({children}) => {
|
|||||||
logout()
|
logout()
|
||||||
setShowSplashScreen(false)
|
setShowSplashScreen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// adding a timeout for 5mins
|
||||||
|
const logOutSession = setTimeout(() => {
|
||||||
|
logout()
|
||||||
|
}, Number(process.env.REACT_APP_LOGOUT_SESSION_TIMEOUT))
|
||||||
|
|
||||||
|
return (() => {
|
||||||
|
clearInterval(logOutSession)
|
||||||
|
})
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [])
|
}, [pathname])
|
||||||
|
|
||||||
return showSplashScreen ? <LayoutSplashScreen /> : <>{children}</>
|
return showSplashScreen ? <LayoutSplashScreen /> : <>{children}</>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user