Skip to content

Commit b0c7988

Browse files
bug getodk#930: changed propertyNotFound to missingParameter, also added test case.
1 parent 4be1293 commit b0c7988

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/resources/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module.exports = (service, endpoint) => {
5555

5656
// TODO/SECURITY: subtle timing attack here.
5757
service.post('/users/reset/initiate', endpoint(({ Users, mail }, { auth, body, query }) =>
58-
(!body.email ? Problem.user.propertyNotFound({ property: 'email' }) : Users.getByEmail(body.email)
58+
(!body.email ? Problem.user.missingParameter({ field: 'email' }) : Users.getByEmail(body.email)
5959
.then((maybeUser) => maybeUser
6060
.map((user) => ((isTrue(query.invalidate))
6161
? auth.canOrReject('user.password.invalidate', user.actor)

test/integration/api/users.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,12 @@ describe('api: /users', () => {
402402
asAlice.post('/v1/users/reset/verify')
403403
.send({ new: 'coolpassword' })
404404
.expect(403))));
405+
406+
it('should fail the request if email field is sent blank in request body', testService((service) =>
407+
service.login('alice', (asAlice) =>
408+
asAlice.post('/v1/users/reset/initiate')
409+
.send({ email: '' })
410+
.expect(400))));
405411
});
406412
}
407413
});

0 commit comments

Comments
 (0)