mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-07 13:11:49 +02:00
🐛 Fix logut menu item
This commit is contained in:
parent
00548ab763
commit
471d98d50b
3 changed files with 12 additions and 24 deletions
|
@ -33,6 +33,7 @@ export const UserContext = React.createContext<{
|
|||
userId?: string | null;
|
||||
guestId?: string | null;
|
||||
}) => boolean;
|
||||
logout: () => Promise<void>;
|
||||
} | null>(null);
|
||||
|
||||
export const useUser = () => {
|
||||
|
@ -105,6 +106,12 @@ export const UserProvider = (props: { children?: React.ReactNode }) => {
|
|||
locale: user.locale ?? i18n.language,
|
||||
},
|
||||
refresh: session.update,
|
||||
logout: async () => {
|
||||
await fetch("/api/logout", { method: "POST" });
|
||||
posthog?.capture("logout");
|
||||
posthog?.reset();
|
||||
window.location.href = "/login";
|
||||
},
|
||||
ownsObject: (resource) => {
|
||||
return isOwner(resource, { id: user.id, isGuest });
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue