mirror of
https://github.com/lukevella/rallly.git
synced 2025-06-05 20:21:50 +02:00
♻️ Keep guest ids in separate column (#1468)
This commit is contained in:
parent
2d7315f45a
commit
5b3c4ad2f6
15 changed files with 171 additions and 58 deletions
|
@ -9,6 +9,7 @@ import { useSubscription } from "@/contexts/plan";
|
|||
import { PreferencesProvider } from "@/contexts/preferences";
|
||||
import { useTranslation } from "@/i18n/client";
|
||||
import { trpc } from "@/trpc/client";
|
||||
import { isOwner } from "@/utils/permissions";
|
||||
|
||||
import { useRequiredContext } from "./use-required-context";
|
||||
|
||||
|
@ -28,7 +29,10 @@ type UserData = {
|
|||
export const UserContext = React.createContext<{
|
||||
user: UserData;
|
||||
refresh: (data?: Record<string, unknown>) => Promise<Session | null>;
|
||||
ownsObject: (obj: { userId?: string | null }) => boolean;
|
||||
ownsObject: (obj: {
|
||||
userId?: string | null;
|
||||
guestId?: string | null;
|
||||
}) => boolean;
|
||||
} | null>(null);
|
||||
|
||||
export const useUser = () => {
|
||||
|
@ -101,8 +105,8 @@ export const UserProvider = (props: { children?: React.ReactNode }) => {
|
|||
locale: user.locale ?? i18n.language,
|
||||
},
|
||||
refresh: session.update,
|
||||
ownsObject: ({ userId }) => {
|
||||
return userId ? [user.id].includes(userId) : false;
|
||||
ownsObject: (resource) => {
|
||||
return isOwner(resource, { id: user.id, isGuest });
|
||||
},
|
||||
}}
|
||||
>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue