mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 17:55:08 +01:00
27 lines
519 B
JavaScript
27 lines
519 B
JavaScript
import { useEffect } from 'react';
|
|
import { useRouter } from 'next/router';
|
|
import useApi from 'hooks/useApi';
|
|
import { setUser } from 'store/app';
|
|
import { removeClientAuthToken } from 'lib/client';
|
|
|
|
export default function LogoutPage() {
|
|
const router = useRouter();
|
|
const { post } = useApi();
|
|
|
|
useEffect(() => {
|
|
async function logout() {
|
|
await post('/logout');
|
|
}
|
|
|
|
removeClientAuthToken();
|
|
|
|
logout();
|
|
|
|
router.push('/login');
|
|
|
|
return () => setUser(null);
|
|
}, []);
|
|
|
|
return null;
|
|
}
|