Celtech/shout-it

View on GitHub
packages/api/src/services/users/users.hooks.js

Summary

Maintainability
A
40 mins
Test Coverage
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('password')],
update: [hashPassword('password'), authenticate('jwt')],
patch: [hashPassword('password'), 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: [],
},
 
Similar blocks of code found in 4 locations. Consider refactoring.
error: {
all: [],
find: [],
get: [],
create: [],
update: [],
patch: [],
remove: [],
},
};