Skip to content

Commit 2886e64

Browse files
committed
refactor: explicitly discard password on get
1 parent 187085e commit 2886e64

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

services/users/users.hooks.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import _ from 'lodash';
22
import { hooks } from '@feathersjs/authentication-local';
3+
import { discard } from 'feathers-hooks-common';
34
import { HookContext } from '@feathersjs/feathers';
45

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

7-
const localDispatch = async (context: HookContext): Promise<HookContext> => {
8-
context.result = context.dispatch;
9-
return context;
10-
};
11-
128
const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => {
139
context.params.query = _.mapValues(context.params.query, data => {
1410
return _.set(data, '$options', 'i');
@@ -19,7 +15,7 @@ const ignoreCaseRegex = async (context: HookContext): Promise<HookContext> => {
1915
export default {
2016
after: {
2117
all: hooks.protect('password'),
22-
get: localDispatch, // Protect password from local get's
18+
get: discard('password'), // Protect password from local get's
2319
},
2420
before: {
2521
find: ignoreCaseRegex,

0 commit comments

Comments
 (0)