mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 06:07:17 +01:00
Updated clients.
This commit is contained in:
parent
a78d11e352
commit
4dedc57d0a
14 changed files with 66 additions and 47 deletions
|
|
@ -2,7 +2,7 @@ import { useEffect } from 'react';
|
|||
import useApi from 'components/hooks/useApi';
|
||||
import useUser from 'components/hooks/useUser';
|
||||
|
||||
export function useRequireLogin(handler?: (data?: object) => void) {
|
||||
export function useRequireLogin() {
|
||||
const { get } = useApi();
|
||||
const { user, setUser } = useUser();
|
||||
|
||||
|
|
@ -11,9 +11,9 @@ export function useRequireLogin(handler?: (data?: object) => void) {
|
|||
try {
|
||||
const data = await get('/auth/verify');
|
||||
|
||||
setUser(typeof handler === 'function' ? handler(data) : (data as any)?.user);
|
||||
setUser(data);
|
||||
} catch {
|
||||
location.href = `${process.env.basePath || ''}/login`;
|
||||
window.location.href = `${process.env.basePath || ''}/login`;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue