mirror of
https://github.com/umami-software/umami.git
synced 2026-02-08 06:37:18 +01:00
Moved code into src folder. Added build for component library.
This commit is contained in:
parent
7a7233ead4
commit
ede658771e
490 changed files with 749 additions and 442 deletions
36
src/pages/logout.js
Normal file
36
src/pages/logout.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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';
|
||||
|
||||
export default function ({ disabled }) {
|
||||
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 async function getServerSideProps() {
|
||||
return {
|
||||
props: {
|
||||
disabled: !!(process.env.DISABLE_LOGIN || process.env.CLOUD_MODE),
|
||||
},
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue