From 2886e64b2d793723d5e8df90725cca1491ba8d6e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 28 Jun 2020 01:26:29 +0300 Subject: refactor: explicitly discard password on get --- services/users/users.hooks.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'services') diff --git a/services/users/users.hooks.ts b/services/users/users.hooks.ts index 398d058..64b322a 100644 --- a/services/users/users.hooks.ts +++ b/services/users/users.hooks.ts @@ -1,14 +1,10 @@ import _ from 'lodash'; import { hooks } from '@feathersjs/authentication-local'; +import { discard } from 'feathers-hooks-common'; import { HookContext } from '@feathersjs/feathers'; const hashPassword = hooks.hashPassword('password'); -const localDispatch = async (context: HookContext): Promise => { - context.result = context.dispatch; - return context; -}; - const ignoreCaseRegex = async (context: HookContext): Promise => { context.params.query = _.mapValues(context.params.query, data => { return _.set(data, '$options', 'i'); @@ -19,7 +15,7 @@ const ignoreCaseRegex = async (context: HookContext): Promise => { export default { after: { all: hooks.protect('password'), - get: localDispatch, // Protect password from local get's + get: discard('password'), // Protect password from local get's }, before: { find: ignoreCaseRegex, -- cgit v1.2.3