From 8e05164678d302700c794feecd50d83357f7719d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 16 Mar 2017 15:50:10 +0100 Subject: feathers stuff --- src/services/user/hooks/index.js | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/services/user/hooks/index.js (limited to 'src/services/user/hooks/index.js') diff --git a/src/services/user/hooks/index.js b/src/services/user/hooks/index.js new file mode 100644 index 0000000..9dfe425 --- /dev/null +++ b/src/services/user/hooks/index.js @@ -0,0 +1,51 @@ +'use strict'; + +const globalHooks = require('../../../hooks'); +const hooks = require('feathers-hooks'); +const auth = require('feathers-authentication').hooks; + +exports.before = { + all: [], + find: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated() + ], + get: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: 'id' }) + ], + create: [ + auth.hashPassword() + ], + update: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: 'id' }) + ], + patch: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: 'id' }) + ], + remove: [ + auth.verifyToken(), + auth.populateUser(), + auth.restrictToAuthenticated(), + auth.restrictToOwner({ ownerField: 'id' }) + ] +}; + +exports.after = { + all: [hooks.remove('password')], + find: [], + get: [], + create: [], + update: [], + patch: [], + remove: [] +}; -- cgit v1.2.3-70-g09d2