feat: assert user is member of workspace for board routes

This commit is contained in:
Henry
2025-05-22 22:12:33 +01:00
parent 71c92eea27
commit 2e97e2be53
5 changed files with 115 additions and 60 deletions

View File

@@ -0,0 +1,22 @@
import { TRPCError } from "@trpc/server";
import type { dbClient } from "@kan/db/client";
import * as workspaceRepo from "@kan/db/repository/workspace.repo";
export async function assertUserInWorkspace(
db: dbClient,
userId: string,
workspaceId: number,
) {
const isMember = await workspaceRepo.isUserInWorkspace(
db,
userId,
workspaceId,
);
if (!isMember)
throw new TRPCError({
message: `You do not have access to this workspace`,
code: "FORBIDDEN",
});
}