Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🔒️ Ignore user input author name (#2020)
Luke Vella9c79a754f584
diff --git a/apps/web/src/trpc/routers/polls/comments.ts b/apps/web/src/trpc/routers/polls/comments.tsindex 4fbeaf980..c47fea6d2 100644--- a/apps/web/src/trpc/routers/polls/comments.ts+++ b/apps/web/src/trpc/routers/polls/comments.ts@@ -80,7 +80,31 @@ export const comments = router({content: z.string().trim().min(1),}),)- .mutation(async ({ ctx, input: { pollId, authorName, content } }) => {+ .mutation(async ({ ctx, input }) => {+ let authorName = input.authorName;++ if (!ctx.user.isGuest) {+ const user = await prisma.user.findUnique({+ where: {+ id: ctx.user.id,+ },+ select: {+ name: true,+ },+ });++ if (!user) {+ throw new TRPCError({+ code: "INTERNAL_SERVER_ERROR",+ message: "User not found",+ });+ }++ authorName = user.name;+ }++ const { content, pollId } = input;+const newComment = await prisma.comment.create({data: {content,