Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hooks should support a callback for conditionally running #210

ekryski opened this Issue May 18, 2016 · 2 comments


None yet
2 participants
Copy link

ekryski commented May 18, 2016

Much like our other built-in hooks you should be able to pass a callback to determine whether the hook should be run.

Usage would be very similar. See docs.


This comment has been minimized.

Copy link
Member Author

ekryski commented Jun 30, 2016

We are going to be deprecating the callback functionality in the other hooks as we have come up with a better, more flexible solution. You can simply wrap any existing hooks in your own, like so:

import { hooks } from 'feathers-authentication';

exports.hashPassword = function(options) {
  // Add any custom options

  function(hook) {
    return new Promise((resolve, reject) => {
      if (myCondition !== true) {
        return resolve(hook);

      // call the original hook
        .then(hook => {
          // do something custom
        .catch(error => {
          // do any custom error handling
          error.message = 'my custom message';

@ekryski ekryski closed this Jun 30, 2016

@ekryski ekryski removed the Backlog label Jun 30, 2016


This comment has been minimized.

Copy link

DominikTrenz commented Dec 18, 2017

I think there is a error in the example.
function(hook) {
should be
return function(hook) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.