Skip to content

Commit a9f0fcf

Browse files
fix: unauthorized access to report listing
Remove staff_view listing option Fix filterByUser
1 parent ef49878 commit a9f0fcf

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/lib/reports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ const getReports = async ({
273273
assignedStaffId: assignedFilter,
274274

275275
...(guildId !== undefined && { guildId: BigInt(guildId) }),
276-
...(filterByUser !== undefined && { userId: BigInt(filterByUser) }),
276+
...(filterByUser !== undefined && { reportingUserId: BigInt(filterByUser) }),
277277
},
278278
orderBy: {
279279
createdAt: "desc",

src/v1/routes/reports.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const GetReportsQuerystring = Type.Object({
3434
guild: Type.Optional(Type.String()),
3535
limit: Type.Optional(Type.Number({ minimum: 1, maximum: 100 })),
3636
skip: Type.Optional(Type.Number()),
37-
staff_view: Type.Optional(Type.Boolean()),
3837
});
3938
type GetReportGuildsQuerystringType = Static<typeof GetReportsQuerystring>;
4039

@@ -172,19 +171,14 @@ const reportPlugin = async (instance: FastifyInstance) => {
172171
},
173172
},
174173
async (request) => {
175-
const { status, assigned_to, guild, limit, skip, staff_view } =
176-
request.query;
174+
const { status, assigned_to, guild, limit, skip } = request.query;
177175

178176
// Can be disabled as these routes are under authentication, and therefore will have a user
179177
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
180178
const user = request.user!;
181179

182-
// Check if staff_view is valid
183-
if (staff_view === true && !user.staff) {
184-
throw new Forbidden("Only staff may request the staff view");
185-
}
186180
let filterByUser: string | undefined;
187-
if (staff_view === false) {
181+
if (!user.staff) {
188182
filterByUser = user.userId;
189183
}
190184

0 commit comments

Comments
 (0)