diff options
Diffstat (limited to 'services/users/users.hooks.ts')
-rw-r--r-- | services/users/users.hooks.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/services/users/users.hooks.ts b/services/users/users.hooks.ts index ee1ae1c..398d058 100644 --- a/services/users/users.hooks.ts +++ b/services/users/users.hooks.ts @@ -1,3 +1,4 @@ +import _ from 'lodash'; import { hooks } from '@feathersjs/authentication-local'; import { HookContext } from '@feathersjs/feathers'; @@ -8,15 +9,23 @@ const localDispatch = async (context: HookContext): Promise<HookContext> => { return context; }; +const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => { + context.params.query = _.mapValues(context.params.query, data => { + return _.set(data, '$options', 'i'); + }); + return context; +}; + export default { after: { - all: [hooks.protect('password')], - get: [localDispatch] // Protect password from local get's + all: hooks.protect('password'), + get: localDispatch, // Protect password from local get's }, before: { - create: [hashPassword], - patch: [hashPassword], - update: [hashPassword] + find: ignoreCaseRegex, + create: hashPassword, + patch: hashPassword, + update: hashPassword } }; |