Is there any way to create a hook that calls 2 different other hooks and then do a ||
between them?
I would like to call the authenticate('jwt')
hook and if this one fails call a custom hook to see if the request is local (so I don't need authentication). If the second hook is positive, I'll go on with the request. If both fail, then it's a no go.
If I call the hooks one after another the first fails and so the service fails.
Can this be achieved or is there a better way to do this?
Thanks in advance
Using feathers-hooks-common you can do an iff
chain, e.g.
const { iff, isProvider } = require('feathers-hooks-common');
module.exports = {
before: {
all: iff(isProvider('external'), authenticate('jwt')
}
}