Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

hashPassword in patch #286

Closed
mcchrish opened this issue Sep 8, 2016 · 2 comments
Closed

hashPassword in patch #286

mcchrish opened this issue Sep 8, 2016 · 2 comments

Comments

@mcchrish
Copy link
Member

mcchrish commented Sep 8, 2016

This check https://github.com/feathersjs/feathers-authentication/blob/master/src/hooks/hash-password.js#L36-L39 is preventing patch methods if password is not defined in the data.

@marshallswain
Copy link
Member

marshallswain commented Sep 8, 2016

Yeah. hashPassword should just hash a password if one is available. I made a PR.

cc: @ekryski, @daffl

Looks like I need to update tests, still. But I don't think this should break anything. Am I missing something?

@mcchrish
Copy link
Member Author

An alternative for now is:

const { hooks } = require('feathers-authentication');

// Your custom hashPassword hook
exports.myHashPassword = function(options) {
  const hashPassword = hooks.hashPassword(options);

  // Add any custom options
  return function(hook) {
    if(hook.data.password !== undefined) {
      // Call the hashPassword hook
      return hashPassword.call(this, hook);
    }
  };
}

Taken from http://docs.feathersjs.com/hooks/usage.html#customizing-built-in-hooks

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants