Skip to content

Commit

Permalink
Merge branch 'master' into session-get-by-bearer-token-missing-return…
Browse files Browse the repository at this point in the history
…-promise
  • Loading branch information
alxndrsn authored Jan 30, 2025
2 parents d41a2b0 + 20e27f3 commit c7a63b7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/resources/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = (service, endpoint) => {

// TODO/SECURITY: subtle timing attack here.
service.post('/users/reset/initiate', endpoint(({ Users, mail }, { auth, body, query }) =>
Users.getByEmail(body.email)
(!body.email ? Problem.user.missingParameter({ field: 'email' }) : Users.getByEmail(body.email)
.then((maybeUser) => maybeUser
.map((user) => ((isTrue(query.invalidate))
? auth.canOrReject('user.password.invalidate', user.actor)
Expand All @@ -71,7 +71,7 @@ module.exports = (service, endpoint) => {
.then((existed) => ((existed === true)
? mail(body.email, 'accountResetDeleted')
: resolve()))))
.then(success))));
.then(success)))));

// TODO: some standard URL structure for RPC-style methods.
service.post('/users/reset/verify', endpoint(({ Actors, Sessions, Users }, { body, auth }) =>
Expand Down
2 changes: 1 addition & 1 deletion test/integration/api/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { getOrNotFound } = require('../../../lib/util/promise');
const should = require('should');
const { sql } = require('slonik');
const { QueryOptions } = require('../../../lib/util/db');
const { createConflict } = require('../fixtures/scenarios');
const { createConflict } = require('../../util/scenarios');
const { omit } = require('ramda');

const { exhaust } = require(appRoot + '/lib/worker/worker');
Expand Down
2 changes: 1 addition & 1 deletion test/integration/api/forms/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const config = require('config');
const { testService } = require('../../setup');
const testData = require('../../../data/xml');

describe('api: /projects/:id/forms (testing drafts)', () => {
describe('api: /test/:key/projects/:id/forms (testing drafts)', () => {

////////////////////////////////////////////////////////////////////////////////
// DRAFT FORM TESTING
Expand Down
2 changes: 1 addition & 1 deletion test/integration/api/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { testService } = require('../setup');
const testData = require('../../data/xml');
const { QueryOptions } = require('../../../lib/util/db');
const { Actor } = require('../../../lib/model/frames');
const { createConflict } = require('../fixtures/scenarios');
const { createConflict } = require('../../util/scenarios');
// eslint-disable-next-line import/no-dynamic-require
const { exhaust } = require(appRoot + '/lib/worker/worker');

Expand Down
10 changes: 10 additions & 0 deletions test/integration/api/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,16 @@ describe('api: /users', () => {
asAlice.post('/v1/users/reset/verify')
.send({ new: 'coolpassword' })
.expect(403))));

it('should fail the request if email field is sent blank in request body', testService((service) =>
service.login('alice', (asAlice) =>
asAlice.post('/v1/users/reset/initiate')
.send({ email: '' })
.expect(400)
.then(({ body: { code, details } }) => {
details.should.eql({ field: 'email' });
code.should.eql(400.2);
}))));
});
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const appRoot = require('app-root-path');
const { exhaust } = require(appRoot + '/lib/worker/worker');
const testData = require('../../data/xml');
const testData = require(appRoot + '/test/data/xml');

const createConflict = async (user, container) => {
await user.post('/v1/projects/1/forms/simpleEntity/submissions')
Expand Down

0 comments on commit c7a63b7

Please sign in to comment.