diff options
Diffstat (limited to 'src/services/users/users.hooks.js')
-rw-r--r-- | src/services/users/users.hooks.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/services/users/users.hooks.js b/src/services/users/users.hooks.js new file mode 100644 index 0000000..613676b --- /dev/null +++ b/src/services/users/users.hooks.js @@ -0,0 +1,41 @@ +const { authenticate } = require('@feathersjs/authentication').hooks; + +const { + hashPassword, protect +} = require('@feathersjs/authentication-local').hooks; + +module.exports = { + before: { + all: [], + find: [ authenticate('jwt') ], + get: [ authenticate('jwt') ], + create: [ hashPassword() ], + update: [ hashPassword(), authenticate('jwt') ], + patch: [ hashPassword(), authenticate('jwt') ], + remove: [ authenticate('jwt') ] + }, + + after: { + all: [ + // Make sure the password field is never sent to the client + // Always must be the last hook + protect('password') + ], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] + }, + + error: { + all: [], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] + } +}; |