Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

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

Luke Vella57406b88435f
diff --git a/apps/web/src/app/[locale]/invite/[urlId]/layout.tsx b/apps/web/src/app/[locale]/invite/[urlId]/layout.tsx
index 2d3ca84cd..78beaefd9 100644
--- a/apps/web/src/app/[locale]/invite/[urlId]/layout.tsx
+++ b/apps/web/src/app/[locale]/invite/[urlId]/layout.tsx
@@ -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();
}
diff --git a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx
index 22e77a084..25b05c955 100644
--- a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx
+++ b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx
@@ -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();
}
diff --git a/apps/web/src/trpc/client/types.ts b/apps/web/src/trpc/client/types.ts
index c52d635a3..b104287f3 100644
--- a/apps/web/src/trpc/client/types.ts
+++ b/apps/web/src/trpc/client/types.ts
@@ -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;
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts
index 74a0c7b34..d2b3f337b 100644
--- a/apps/web/src/trpc/routers/polls.ts
+++ b/apps/web/src/trpc/routers/polls.ts
@@ -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,