Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/verifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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`);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note this additional change. Master did not use the apparently new username constant defined on line 72. Figured it was a quick fix :)

}
return this._normalizeResult(response)
})
Expand Down
18 changes: 17 additions & 1 deletion test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' }))
Expand All @@ -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' })
}
});
Expand All @@ -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');
});
});
});
Expand Down