mirror of
https://github.com/umami-software/umami.git
synced 2026-02-09 23:27:12 +01:00
Refactored to use app folder.
This commit is contained in:
parent
40cfcd41e9
commit
9a52cdd2e1
258 changed files with 2025 additions and 2258 deletions
34
src/app/logout/page.tsx
Normal file
34
src/app/logout/page.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
'use client';
|
||||
import { useEffect } from 'react';
|
||||
import { useRouter } from 'next/router';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
import { setUser } from 'store/app';
|
||||
import { removeClientAuthToken } from 'lib/client';
|
||||
|
||||
async function getDisabled() {
|
||||
return !!(process.env.DISABLE_LOGIN || process.env.CLOUD_MODE);
|
||||
}
|
||||
|
||||
export default async function LogoutPage() {
|
||||
const disabled = await getDisabled();
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue