diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-28 01:26:29 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-28 01:26:29 +0300 |
commit | 2886e64b2d793723d5e8df90725cca1491ba8d6e (patch) | |
tree | 88d5bffc34837568e119dcf059f9f532134675a9 | |
parent | 187085ec11fe9ab744a9105dfd258254b2ddd35c (diff) | |
download | which-api-2886e64b2d793723d5e8df90725cca1491ba8d6e.tar.gz |
refactor: explicitly discard password on get
-rw-r--r-- | services/users/users.hooks.ts | 8 |
1 files changed, 2 insertions, 6 deletions
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<HookContext> => { - context.result = context.dispatch; - return context; -}; - const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => { context.params.query = _.mapValues(context.params.query, data => { return _.set(data, '$options', 'i'); @@ -19,7 +15,7 @@ const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => { 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, |