Skip to content

Commit

Permalink
make tenantid come from user session
Browse files Browse the repository at this point in the history
  • Loading branch information
N7Remus authored Feb 17, 2025
1 parent fe14031 commit f054c40
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/services/groups/groups.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export const groupDataSchema = Type.Pick(groupSchema, [ 'name' ], {
});
export type GroupData = Static<typeof groupDataSchema>
export const groupDataValidator = getValidator(groupDataSchema, dataValidator);
export const groupDataResolver = resolve<Group, HookContext>({});
export const groupDataResolver = resolve<Group, HookContext>({
tenantId: async (value, query, context) => {
// Make sure the user is limited to their own tenant
if (context.params.user)
return context.params.user.tenantId;

return value;
}
});

// Schema for updating existing entries
export const groupPatchSchema = Type.Partial(groupSchema, {
Expand Down

0 comments on commit f054c40

Please sign in to comment.