Skip to content

Commit fd7db66

Browse files
committed
Bug: Database query built from user-controlled sources
1 parent 32e153d commit fd7db66

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/controllers/v4/internal/notification.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const markNotificationAsRead = async (req, res) => {
6666
return res.status(400).json({ message: 'User ID is required' });
6767
}
6868
// Check if the global notification exists
69-
const notificationExists = await Notification.exists({ _id: id });
69+
const notificationExists = await Notification.exists({ _id: { $eq: id } });
7070
if (!notificationExists) {
7171
return res.status(404).json({ message: 'Global notification not found' });
7272
}
@@ -79,7 +79,7 @@ const markNotificationAsRead = async (req, res) => {
7979
);
8080
} else {
8181
// Update read status for user-specific notifications
82-
await UserNotification.findOneAndUpdate({ _id: id }, { read: true });
82+
await UserNotification.findOneAndUpdate({ _id: { $eq: id } }, { read: true });
8383
}
8484

8585
return res.status(200).json({ message: 'Notification marked as read' });
@@ -111,7 +111,7 @@ const markNotificationAsDeleted = async (req, res) => {
111111
return res.status(400).json({ message: 'User ID is required' });
112112
}
113113
// Check if the global notification exists
114-
const notificationExists = await Notification.exists({ _id: id });
114+
const notificationExists = await Notification.exists({ _id: { $eq: id } });
115115
if (!notificationExists) {
116116
return res.status(404).json({ message: 'Global notification not found' });
117117
}
@@ -124,7 +124,7 @@ const markNotificationAsDeleted = async (req, res) => {
124124
);
125125
} else {
126126
// Update deleted status for user-specific notifications
127-
await UserNotification.findOneAndUpdate({ _id: id }, { deleted: true });
127+
await UserNotification.findOneAndUpdate({ _id: { $eq: id } }, { deleted: true });
128128
}
129129

130130
return res.status(200).json({ message: 'Notification marked as deleted' });

0 commit comments

Comments
 (0)