Skip to content

Commit e670c1e

Browse files
fix: add runtime date validation for updatedSince query param
1 parent e6ccc9c commit e670c1e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

apps/meteor/app/api/server/v1/roles.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,16 @@ const rolesRoutes = API.v1
272272
async function () {
273273
const { updatedSince } = this.queryParams;
274274

275+
if (isNaN(Date.parse(updatedSince))) {
276+
throw new Meteor.Error('error-updatedSince-param-invalid', 'The "updatedSince" query parameter must be a valid date.');
277+
}
278+
279+
const updatedSinceDate = new Date(updatedSince);
280+
275281
return API.v1.success({
276282
roles: {
277-
update: await Roles.findByUpdatedDate(new Date(updatedSince)).toArray(),
278-
remove: await Roles.trashFindDeletedAfter(new Date(updatedSince)).toArray(),
283+
update: await Roles.findByUpdatedDate(updatedSinceDate).toArray(),
284+
remove: await Roles.trashFindDeletedAfter(updatedSinceDate).toArray(),
279285
},
280286
});
281287
},

0 commit comments

Comments
 (0)