Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
feat: add validation for notification settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwigoric committed Nov 29, 2023
1 parent 96fcf3b commit bdb55ad
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/routes/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ router.patch('/notifications', async (req, res, next) => {
if (err) return next(err)
if (!admin) return res.status(401).json({ message: info.message })

if (
req.body.demand_letter >= req.body.third_notice ||
req.body.third_notice >= req.body.second_notice ||
req.body.second_notice >= req.body.first_notice ||
req.body.first_notice >= req.body.reminder
)
return res.status(400).json({
message: 'The order of the notifications is not correct',
error: true
})

try {
await NotificationSettings.findOneAndUpdate({}, req.body).select('-_id -__v')

Expand Down

0 comments on commit bdb55ad

Please sign in to comment.