fix: Convert ints to strings for validation
This commit is contained in:
committed by
mrugesh mohapatra
parent
014c26cd4e
commit
f743f4edf5
@ -199,7 +199,7 @@ export function isValidChallengeCompletion(req, res, next) {
|
||||
log('isObjectId', id, ObjectID.isValid(id));
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
if ('challengeType' in req.body && !isNumeric(challengeType)) {
|
||||
if ('challengeType' in req.body && !isNumeric(String(challengeType))) {
|
||||
log('challengeType', challengeType, isNumeric(challengeType));
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
|
@ -310,6 +310,21 @@ describe('boot/challenge', () => {
|
||||
|
||||
expect(next.called).toBe(true);
|
||||
});
|
||||
|
||||
it('can handle an "int" challengeType', () => {
|
||||
const req = mockReq({
|
||||
body: {
|
||||
id: validObjectId,
|
||||
challengeType: 1
|
||||
}
|
||||
});
|
||||
const res = mockRes();
|
||||
const next = sinon.spy();
|
||||
|
||||
isValidChallengeCompletion(req, res, next);
|
||||
|
||||
expect(next.called).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
xdescribe('modernChallengeCompleted');
|
||||
|
Reference in New Issue
Block a user