aboutsummaryrefslogtreecommitdiff
path: root/services/users/users.hooks.ts
diff options
context:
space:
mode:
Diffstat (limited to 'services/users/users.hooks.ts')
-rw-r--r--services/users/users.hooks.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/services/users/users.hooks.ts b/services/users/users.hooks.ts
index ee1ae1c..48843be 100644
--- a/services/users/users.hooks.ts
+++ b/services/users/users.hooks.ts
@@ -1,22 +1,27 @@
+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;
+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: discard('password') // Protect password from local get's
},
before: {
- create: [hashPassword],
- patch: [hashPassword],
- update: [hashPassword]
+ find: ignoreCaseRegex,
+ create: hashPassword,
+ patch: hashPassword,
+ update: hashPassword
}
};