feathersjs-ecosystem/feathers-authentication-management

hooks.addVerification should also be possible in Before Patch and Update hooks

Closed this issue · 4 comments

Steps to reproduce

  • Add verifyHooks.addVerification() into a before PATCH or PUT hook.

As said in the docs, there are now many ways for users to log in (social media, sms etc). My primary login is a public key / private key login, and the email field is optional.

So I want to add this hook on patch/put hooks, when the user changes his email. Are there any big no-gos for this feature?

Expected behavior

It should work.

Actual behavior

An error is thrown: The 'anonymous' hook can only be used on the '["create"]' service method(s).

System configuration

Not relevant

I think what you want to do should work, though I looked at the code just briefly.

You'd have to change to hook to checkContext(hook, 'before', ['create', 'update', 'patch']); as well as calling it for patch only if relavent fields are being changed.

I can work on a PR for this.

Perhaps you can first make sure it works. :)

handled in #62