mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 15:17:23 +01:00
Fix CSS. Updated pages.
This commit is contained in:
parent
0f12226401
commit
3720a5a2fc
12 changed files with 71 additions and 71 deletions
32
src/app/logout/Logout.js
Normal file
32
src/app/logout/Logout.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
'use client';
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import { setUser } from 'store/app';
|
||||
import { removeClientAuthToken } from 'lib/client';
|
||||
|
||||
export function Logout() {
|
||||
const disabled = !!(process.env.disableLogin || process.env.cloudMode);
|
||||
const router = useRouter();
|
||||
const { post } = useApi();
|
||||
|
||||
useEffect(() => {
|
||||
async function logout() {
|
||||
await post('/auth/logout');
|
||||
}
|
||||
|
||||
if (!disabled) {
|
||||
removeClientAuthToken();
|
||||
|
||||
logout();
|
||||
|
||||
router.push('/login');
|
||||
|
||||
return () => setUser(null);
|
||||
}
|
||||
}, [disabled, router, post]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export default Logout;
|
||||
Loading…
Add table
Add a link
Reference in a new issue