Skip to content

Commit

Permalink
Fixed login redirect.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecao committed Sep 22, 2023
1 parent 326bc9f commit 424f3e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.components.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@umami/components",
"version": "0.11.0",
"version": "0.1.0",
"description": "Umami React components.",
"author": "Mike Cao <[email protected]>",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/components/hooks/useRequireLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import useApi from 'components/hooks/useApi';
import useUser from 'components/hooks/useUser';

export function useRequireLogin(handler: (data?: object) => void) {
const router = useRouter();
const { basePath } = useRouter();
const { get } = useApi();
const { user, setUser } = useUser();

Expand All @@ -15,7 +15,7 @@ export function useRequireLogin(handler: (data?: object) => void) {

setUser(typeof handler === 'function' ? handler(data) : (data as any)?.user);
} catch {
await router.push('/login');
location.href = `${basePath}/login`;
}
}

Expand Down

0 comments on commit 424f3e5

Please sign in to comment.