fix(users): correct auth middleware for web push subscription (#3005)

This commit is contained in:
Gauthier
2026-05-09 11:18:22 +02:00
committed by GitHub
parent 99f8520f48
commit bd27f2de6b

View File

@@ -324,8 +324,8 @@ router.post<
}
});
router.get<{ userId: string }>(
'/:userId/pushSubscriptions',
router.get<{ id: string }>(
'/:id/pushSubscriptions',
isOwnProfileOrAdmin(),
async (req, res, next) => {
try {
@@ -333,7 +333,7 @@ router.get<{ userId: string }>(
const userPushSubs = await userPushSubRepository.find({
relations: { user: true },
where: { user: { id: Number(req.params.userId) } },
where: { user: { id: Number(req.params.id) } },
});
return res.status(200).json(userPushSubs);
@@ -343,8 +343,8 @@ router.get<{ userId: string }>(
}
);
router.get<{ userId: string; endpoint: string }>(
'/:userId/pushSubscription/:endpoint',
router.get<{ id: string; endpoint: string }>(
'/:id/pushSubscription/:endpoint',
isOwnProfileOrAdmin(),
async (req, res, next) => {
try {
@@ -355,7 +355,7 @@ router.get<{ userId: string; endpoint: string }>(
user: true,
},
where: {
user: { id: Number(req.params.userId) },
user: { id: Number(req.params.id) },
endpoint: req.params.endpoint,
},
});
@@ -367,8 +367,8 @@ router.get<{ userId: string; endpoint: string }>(
}
);
router.delete<{ userId: string; endpoint: string }>(
'/:userId/pushSubscription/:endpoint',
router.delete<{ id: string; endpoint: string }>(
'/:id/pushSubscription/:endpoint',
isOwnProfileOrAdmin(),
async (req, res, next) => {
try {
@@ -377,7 +377,7 @@ router.delete<{ userId: string; endpoint: string }>(
const userPushSub = await userPushSubRepository.findOne({
relations: { user: true },
where: {
user: { id: Number(req.params.userId) },
user: { id: Number(req.params.id) },
endpoint: req.params.endpoint,
},
});