blob: 48843beaea0cb52962af973c7e28b6a6e0f04c92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 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: discard('password') // Protect password from local get's
},
before: {
find: ignoreCaseRegex,
create: hashPassword,
patch: hashPassword,
update: hashPassword
}
};
|