1
0
mirror of https://github.com/kremalicious/umami.git synced 2024-12-21 00:33:39 +01:00
umami/pages/logout.js
2020-11-09 21:20:04 -08:00

19 lines
489 B
JavaScript

import { useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { useRouter } from 'next/router';
import { get } from 'lib/web';
import { updateUser } from 'redux/actions/user';
export default function LogoutPage() {
const dispatch = useDispatch();
const router = useRouter();
const { basePath } = router;
useEffect(() => {
dispatch(updateUser(null));
get(`${basePath}/api/auth/logout`).then(() => router.push('/login'));
}, []);
return null;
}