Skip to content

Commit

Permalink
fix(delete): check permission...
Browse files Browse the repository at this point in the history
  • Loading branch information
flowergardn committed Dec 16, 2023
1 parent 8582ebe commit 74a3c85
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/server/api/routers/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@ export const cardRouter = createTRPCRouter({
}),
)
.mutation(async ({ ctx, input }) => {
const card = await ctx.db.cards.findUnique({
where: {
id: input.cardId,
creatorId: ctx.userId,
},
});

if (!card)
throw new TRPCError({
code: "NOT_FOUND",
});

return await ctx.db.cards.delete({
where: {
id: input.cardId,
Expand Down

0 comments on commit 74a3c85

Please sign in to comment.