Skip to content

Commit b7d307b

Browse files
authored
fix(event): replace organizerId with organizer public fields in GET /:slug response (#346)
The event detail endpoint was returning the raw organizer UUID via organizerId, leaking an internal database identifier to unauthenticated callers. Fetch the organizer relation and expose organizerUsername and organizerDisplayName instead.
1 parent c5f3cc2 commit b7d307b

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

apps/backend/src/routes/event.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@ import {generateUniqueSlug} from '../utils/slug'
55

66

77
type EventDetails = {
8-
id: string;
9-
name: string;
10-
slug: string;
11-
location: string;
12-
description: string | null;
13-
organizerId: string;
14-
startDate: Date;
15-
endDate: Date;
16-
createdAt: Date;
8+
id: string;
9+
name: string;
10+
slug: string;
11+
location: string;
12+
description: string | null;
13+
organizerUsername: string;
14+
organizerDisplayName: string;
15+
startDate: Date;
16+
endDate: Date;
17+
createdAt: Date;
1718
attendeesCount: number
1819
}
1920

@@ -115,13 +116,19 @@ export async function eventRoutes(app:FastifyInstance) {
115116
const paramsSlug = request.params.slug;
116117
const details = await app.prisma.event.findUnique({
117118
where: {
118-
slug : paramsSlug,
119+
slug: paramsSlug,
119120
},
120121
include: {
121122
_count: {
122123
select: {
123124
attendees: true
124125
}
126+
},
127+
organizer: {
128+
select: {
129+
username: true,
130+
displayName: true
131+
}
125132
}
126133
}
127134
})
@@ -131,14 +138,15 @@ export async function eventRoutes(app:FastifyInstance) {
131138

132139
const response: EventDetails = {
133140
id: details.id,
134-
name: details.name,
135-
slug: details.slug,
141+
name: details.name,
142+
slug: details.slug,
136143
description: details.description,
137144
location: details.location,
138-
organizerId: details.organizerId,
145+
organizerUsername: details.organizer.username,
146+
organizerDisplayName: details.organizer.displayName,
139147
startDate: details.startDate,
140-
endDate: details.endDate,
141-
createdAt: details.createdAt,
148+
endDate: details.endDate,
149+
createdAt: details.createdAt,
142150
attendeesCount: details._count.attendees
143151
}
144152

0 commit comments

Comments
 (0)