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 }),
]);
if (!poll || poll.deleted) {
if (!poll || poll.deleted || poll.user?.banned) {
notFound();
}

View file

@ -56,6 +56,7 @@ export async function generateMetadata({
user: {
select: {
name: true,
banned: true,
},
},
},
@ -63,7 +64,7 @@ export async function generateMetadata({
const { t } = await getTranslation(locale);
if (!poll || poll.deleted) {
if (!poll || poll.deleted || poll.user?.banned) {
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 = {
id: string;
@ -6,7 +6,13 @@ export type GetPollApiResponse = {
location: string | null;
description: string | null;
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;
adminUrlId: string;
status: PollStatus;

View file

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