Block access to all polls for banned user (#1606)

This commit is contained in:
Luke Vella 2025-03-03 20:09:11 +00:00 committed by GitHub
parent 7697270cf5
commit 57406b8843
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 5 deletions

View file

@ -20,7 +20,7 @@ export default async function Layout({
trpc.polls.comments.list.prefetch({ pollId: params.urlId }), trpc.polls.comments.list.prefetch({ pollId: params.urlId }),
]); ]);
if (!poll || poll.deleted) { if (!poll || poll.deleted || poll.user?.banned) {
notFound(); notFound();
} }

View file

@ -56,6 +56,7 @@ export async function generateMetadata({
user: { user: {
select: { select: {
name: true, name: true,
banned: true,
}, },
}, },
}, },
@ -63,7 +64,7 @@ export async function generateMetadata({
const { t } = await getTranslation(locale); const { t } = await getTranslation(locale);
if (!poll || poll.deleted) { if (!poll || poll.deleted || poll.user?.banned) {
notFound(); notFound();
} }

View file

@ -1,4 +1,4 @@
import type { PollStatus, User, VoteType } from "@rallly/database"; import type { PollStatus, VoteType } from "@rallly/database";
export type GetPollApiResponse = { export type GetPollApiResponse = {
id: string; id: string;
@ -6,7 +6,13 @@ export type GetPollApiResponse = {
location: string | null; location: string | null;
description: string | null; description: string | null;
options: { id: string; startTime: Date; duration: number }[]; options: { id: string; startTime: Date; duration: number }[];
user: User | null; user: {
id: string;
name: string;
email: string | null;
image: string | null;
banned: boolean;
} | null;
timeZone: string | null; timeZone: string | null;
adminUrlId: string; adminUrlId: string;
status: PollStatus; status: PollStatus;

View file

@ -446,7 +446,15 @@ export const polls = router({
startTime: "asc", startTime: "asc",
}, },
}, },
user: true, user: {
select: {
id: true,
name: true,
email: true,
image: true,
banned: true,
},
},
userId: true, userId: true,
guestId: true, guestId: true,
deleted: true, deleted: true,