-
Notifications
You must be signed in to change notification settings - Fork 15
Support dot notation #7
Comments
I confirm, this would be awesome. I talked about that in the #help channel on Slack. If you don't use a flat structure in your user service response (for example with JSON API standard), you simply can't do anything. I'm currently commenting the line 52 of verifier.js with my own path, but that's not good. Let me know if we can help. Cheers, Lionel |
The workaround right now is to implement your own verifier methods. It's a good feature though and definitely worth adding. We'll happily accept a pull request with tests that changes https://github.com/feathersjs/feathers-authentication-local/blob/master/src/verifier.js#L23 to use lodash .get: const hash = get(entity, this.options.passwordField); |
You can probably copy the test from https://github.com/feathersjs/feathers-authentication-local/blob/master/test/verifier.test.js#L92-L98 to the next line and change it to this describe('password comparison succeeds', () => {
it('allows dot notation for password field', () => {
const oldPasswordField = verifier.options.passwordField;
verifier.options.passwordField = 'nested.password';
return verifier._comparePassword({
nested: user
}, 'admin').then(result => {
expect(result).to.deep.equal(user);
verifier.options.passwordField = oldPaswordField;
});
});
}); |
Thanks @daffl and @theonlyelf, looking forward to use it! |
We've decided to remove the For now, it's a better idea to write your own custom verifier function that queries documents with dot notation. |
Awesome, thanks. I finally ended up doing my own Verifier for exactly this reason. |
@lionelrudaz do you have an example? I haven't gotten the chance to hop in an write my own yet. |
Sure, here it is: https://github.com/lionelrudaz/api.wellnow.ch/blob/master/src/verifier.js I call it from the app: https://github.com/lionelrudaz/api.wellnow.ch/blob/master/src/app.js Hope this helps. |
This is just a simple feature request, but it'd be great if
usernameField
andpasswordField
both supported dot notation.The text was updated successfully, but these errors were encountered: