Skip to content

Commit bd27f2d

Browse files
authored
fix(users): correct auth middleware for web push subscription (#3005)
1 parent 99f8520 commit bd27f2d

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

server/routes/user/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,16 @@ router.post<
324324
}
325325
});
326326

327-
router.get<{ userId: string }>(
328-
'/:userId/pushSubscriptions',
327+
router.get<{ id: string }>(
328+
'/:id/pushSubscriptions',
329329
isOwnProfileOrAdmin(),
330330
async (req, res, next) => {
331331
try {
332332
const userPushSubRepository = getRepository(UserPushSubscription);
333333

334334
const userPushSubs = await userPushSubRepository.find({
335335
relations: { user: true },
336-
where: { user: { id: Number(req.params.userId) } },
336+
where: { user: { id: Number(req.params.id) } },
337337
});
338338

339339
return res.status(200).json(userPushSubs);
@@ -343,8 +343,8 @@ router.get<{ userId: string }>(
343343
}
344344
);
345345

346-
router.get<{ userId: string; endpoint: string }>(
347-
'/:userId/pushSubscription/:endpoint',
346+
router.get<{ id: string; endpoint: string }>(
347+
'/:id/pushSubscription/:endpoint',
348348
isOwnProfileOrAdmin(),
349349
async (req, res, next) => {
350350
try {
@@ -355,7 +355,7 @@ router.get<{ userId: string; endpoint: string }>(
355355
user: true,
356356
},
357357
where: {
358-
user: { id: Number(req.params.userId) },
358+
user: { id: Number(req.params.id) },
359359
endpoint: req.params.endpoint,
360360
},
361361
});
@@ -367,8 +367,8 @@ router.get<{ userId: string; endpoint: string }>(
367367
}
368368
);
369369

370-
router.delete<{ userId: string; endpoint: string }>(
371-
'/:userId/pushSubscription/:endpoint',
370+
router.delete<{ id: string; endpoint: string }>(
371+
'/:id/pushSubscription/:endpoint',
372372
isOwnProfileOrAdmin(),
373373
async (req, res, next) => {
374374
try {
@@ -377,7 +377,7 @@ router.delete<{ userId: string; endpoint: string }>(
377377
const userPushSub = await userPushSubRepository.findOne({
378378
relations: { user: true },
379379
where: {
380-
user: { id: Number(req.params.userId) },
380+
user: { id: Number(req.params.id) },
381381
endpoint: req.params.endpoint,
382382
},
383383
});

0 commit comments

Comments
 (0)