From 1309e462efc4a7bbdf538e9d209133c1b3c138a6 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 25 Oct 2018 22:22:55 +0200 Subject: Added authentication and post endpoint --- src/services/users/users.hooks.js | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/services/users/users.hooks.js (limited to 'src/services/users/users.hooks.js') 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: [] + } +}; -- cgit v1.2.3