This commit is contained in:
john 2025-05-17 23:18:37 +02:00
parent 313f1def49
commit 36f5eef849
12 changed files with 39 additions and 23 deletions

View file

@ -1,6 +1,7 @@
import { useNavigate } from 'react-router-dom'
import { AuthService } from '../authService.ts'
import { useEffect } from 'react'
import { useUser } from '../../user/userStore.ts'
interface LogoutPageProps {
authService: AuthService
@ -8,15 +9,18 @@ interface LogoutPageProps {
export default function LogoutPage({ authService }: LogoutPageProps) {
const navigate = useNavigate()
const { user } = useUser()
useEffect(() => {
const timeout = setTimeout(async () => {
if (!user) {
navigate('/login')
await authService.logout()
})
}
}, [user, navigate])
useEffect(() => {
const timeout = setTimeout(() => authService.logout())
return () => clearTimeout(timeout)
}, [authService, navigate])
}, [authService])
return <></>
}