Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🔒️ Check poll admin privilage before mutation (#2191)
Luke Vella99e4b9b684a3
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.tsindex b1a66cb8f..304447a0f 100644--- a/apps/web/src/trpc/routers/polls.ts+++ b/apps/web/src/trpc/routers/polls.ts@@ -391,6 +391,13 @@ export const polls = router({.mutation(async ({ input, ctx }) => {const pollId = await getPollIdFromAdminUrlId(input.urlId);+ if (!(await hasPollAdminAccess(pollId, ctx.user.id))) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "You do not have permission to update this poll",+ });+ }+if (input.optionsToDelete && input.optionsToDelete.length > 0) {await prisma.option.deleteMany({where: {@@ -579,6 +586,14 @@ export const polls = router({.use(requireUserMiddleware).mutation(async ({ input: { urlId }, ctx }) => {const pollId = await getPollIdFromAdminUrlId(urlId);++ if (!(await hasPollAdminAccess(pollId, ctx.user.id))) {+ throw new TRPCError({+ code: "FORBIDDEN",+ message: "You do not have permission to delete this poll",+ });+ }+await prisma.poll.update({where: { id: pollId },data: { deleted: true, deletedAt: new Date() },