add a keep alive session loop

pull/118/head
maxime 1 year ago
parent 6738ddcb67
commit fa7339b0f1

@ -17,6 +17,8 @@ const NewTacticPage = lazy(() => import("./pages/NewTacticPage.tsx"))
const Editor = lazy(() => import("./pages/Editor.tsx"))
const Settings = lazy(() => import("./pages/Settings.tsx"))
const TOKEN_REFRESH_INTERVAL_MS = 60 * 1000
export default function App() {
function suspense(node: ReactNode) {
return (
@ -37,6 +39,16 @@ export default function App() {
storeAuthentication(auth)
}, [fetcher])
useEffect(() => {
const interval = setInterval(() => {
fetcher.fetchAPIGet("auth/keep-alive")
console.log("KEPT ALIVE !")
}, TOKEN_REFRESH_INTERVAL_MS)
return () => clearInterval(interval)
}, [fetcher])
return (
<div id="app">
<FetcherContext.Provider value={fetcher}>

@ -33,7 +33,6 @@ export default function LoginApp({onSuccess}: LoginAppProps) {
const { token, expirationDate } = await response.json()
const auth = { token, expirationDate: new Date(expirationDate) }
onSuccess(auth)
console.log(location)
navigate(location.state?.from || "/")
return
}

@ -46,8 +46,6 @@ function ProfilSettings() {
const [modalShow, setModalShow] = useState(false)
const width = 150
console.log(user)
const profilePicture = user!.profilePicture
return (
<Container>
@ -101,7 +99,6 @@ function ProfilSettings() {
const password = passwordRef.current?.value
const confirmPassword = confirmPasswordRef.current?.value
console.log(password, confirmPassword, name, email)
if (password !== confirmPassword) {
setErrorMessages(["Les mots de passe ne correspondent pas !"])
return
@ -207,8 +204,6 @@ async function imageExists(imageLink: string) {
try {
const response = await fetch(imageLink)
console.log(response)
if (response.ok) {
const contentType = response.headers.get("content-type")
return contentType?.startsWith("image/") ?? false

Loading…
Cancel
Save