@@ -18,6 +18,7 @@ import {
18
18
DatabaseInsertError ,
19
19
DiscordEventError ,
20
20
NotFoundError ,
21
+ UnauthenticatedError ,
21
22
ValidationError ,
22
23
} from "../../common/errors/index.js" ;
23
24
import { randomUUID } from "crypto" ;
@@ -236,6 +237,9 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
236
237
} ,
237
238
} ,
238
239
async ( request , reply ) => {
240
+ if ( ! request . username ) {
241
+ throw new UnauthenticatedError ( { message : "Username not found." } ) ;
242
+ }
239
243
try {
240
244
let originalEvent ;
241
245
const userProvidedId = (
@@ -281,6 +285,7 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
281
285
await updateDiscord (
282
286
fastify . secretsManagerClient ,
283
287
entry ,
288
+ request . username ,
284
289
false ,
285
290
request . log ,
286
291
) ;
@@ -360,6 +365,9 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
360
365
} ,
361
366
async ( request : FastifyRequest < EventDeleteRequest > , reply ) => {
362
367
const id = request . params . id ;
368
+ if ( ! request . username ) {
369
+ throw new UnauthenticatedError ( { message : "Username not found." } ) ;
370
+ }
363
371
try {
364
372
await fastify . dynamoClient . send (
365
373
new DeleteItemCommand ( {
@@ -370,6 +378,7 @@ const eventsPlugin: FastifyPluginAsync = async (fastify, _options) => {
370
378
await updateDiscord (
371
379
fastify . secretsManagerClient ,
372
380
{ id } as IUpdateDiscord ,
381
+ request . username ,
373
382
true ,
374
383
request . log ,
375
384
) ;
0 commit comments