diff --git a/src/verifier.js b/src/verifier.js index 5cecc2a..1a97dd7 100644 --- a/src/verifier.js +++ b/src/verifier.js @@ -2,6 +2,7 @@ import Debug from 'debug'; import errors from 'feathers-errors'; import bcrypt from 'bcryptjs'; import get from 'lodash.get'; +import omit from 'lodash.omit'; const debug = Debug('feathers-authentication-local:verify'); @@ -71,17 +72,19 @@ class LocalVerifier { // Choose username field const usernameField = this.options.entityUsernameField || this.options.usernameField; - const query = { - [usernameField]: username, - $limit: 1 - }; + const params = Object.assign({ + 'query': { + [usernameField]: username, + '$limit': 1 + } + }, omit(req.params, 'query', 'provider', 'headers', 'session', 'cookies')); // Look up the entity - this.service.find({ query }) + this.service.find(params) .then(response => { const results = response.data || response if (!results.length) { - debug(`a record with ${this.options.usernameField} of '${username}' did not exist`); + debug(`a record with ${usernameField} of '${username}' did not exist`); } return this._normalizeResult(response) }) diff --git a/test/integration.test.js b/test/integration.test.js index 9c86cdc..bfde539 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -16,10 +16,20 @@ describe('integration', () => { query: {}, body: Object.assign({}, User), headers: {}, - cookies: {} + cookies: {}, + params: { + query: {}, + provider: 'socketio', + headers: {}, + session: {}, + cookies: {}, + data: 'Hello, world' + } }; const app = feathers(); + let paramsReceived = false; + let dataReceived; app.configure(hooks()) .configure(authentication({ secret: 'secret' })) @@ -28,6 +38,10 @@ describe('integration', () => { app.service('users').hooks({ before: { + find: (hook) => { + paramsReceived = Object.keys(hook.params); + dataReceived = hook.params.data; + }, create: local.hooks.hashPassword({ passwordField: 'password' }) } }); @@ -39,6 +53,8 @@ describe('integration', () => { expect(result.success).to.equal(true); expect(result.data.user.email).to.equal(User.email); expect(result.data.user.password).to.not.equal(undefined); + expect(paramsReceived).to.have.members(['data', 'query']); + expect(dataReceived).to.equal('Hello, world'); }); }); });