1
0
mirror of https://github.com/kremalicious/umami.git synced 2024-12-22 17:23:54 +01:00
umami/pages/logout.js

19 lines
489 B
JavaScript
Raw Normal View History

2020-08-05 07:45:05 +02:00
import { useEffect } from 'react';
2020-11-10 06:20:04 +01:00
import { useDispatch } from 'react-redux';
2020-10-01 07:34:16 +02:00
import { useRouter } from 'next/router';
2020-11-10 06:01:53 +01:00
import { get } from 'lib/web';
2020-11-10 06:20:04 +01:00
import { updateUser } from 'redux/actions/user';
2020-07-26 01:31:07 +02:00
export default function LogoutPage() {
2020-11-10 06:20:04 +01:00
const dispatch = useDispatch();
2020-10-01 07:34:16 +02:00
const router = useRouter();
const { basePath } = router;
2020-08-05 07:45:05 +02:00
useEffect(() => {
2020-11-10 06:20:04 +01:00
dispatch(updateUser(null));
2020-11-10 06:01:53 +01:00
get(`${basePath}/api/auth/logout`).then(() => router.push('/login'));
2020-08-05 07:45:05 +02:00
}, []);
2020-07-26 01:31:07 +02:00
2020-08-05 07:45:05 +02:00
return null;
2020-07-26 01:31:07 +02:00
}