wip
This commit is contained in:
parent
313f1def49
commit
36f5eef849
12 changed files with 39 additions and 23 deletions
|
@ -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 <></>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue