aboutsummaryrefslogtreecommitdiff
path: root/services/users/users.hooks.ts
blob: ee1ae1c5800a7093f7f0704ef4e7a8f207bd0d59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { hooks } from '@feathersjs/authentication-local';
import { HookContext } from '@feathersjs/feathers';

const hashPassword = hooks.hashPassword('password');

const localDispatch = async (context: HookContext): Promise<HookContext> => {
  context.result = context.dispatch;
  return context;
};

export default {
  after: {
    all: [hooks.protect('password')],
    get: [localDispatch] // Protect password from local get's
  },
  before: {
    create: [hashPassword],
    patch: [hashPassword],
    update: [hashPassword]
  }
};