File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change
1
+ import _ from 'lodash' ;
1
2
import { hooks } from '@feathersjs/authentication-local' ;
2
3
import { HookContext } from '@feathersjs/feathers' ;
3
4
@@ -8,15 +9,23 @@ const localDispatch = async (context: HookContext): Promise<HookContext> => {
8
9
return context ;
9
10
} ;
10
11
12
+ const ignoreCaseRegex = async ( context : HookContext ) : Promise < HookContext > => {
13
+ context . params . query = _ . mapValues ( context . params . query , data => {
14
+ return _ . set ( data , '$options' , 'i' ) ;
15
+ } ) ;
16
+ return context ;
17
+ } ;
18
+
11
19
export default {
12
20
after : {
13
- all : [ hooks . protect ( 'password' ) ] ,
14
- get : [ localDispatch ] // Protect password from local get's
21
+ all : hooks . protect ( 'password' ) ,
22
+ get : localDispatch , // Protect password from local get's
15
23
} ,
16
24
before : {
17
- create : [ hashPassword ] ,
18
- patch : [ hashPassword ] ,
19
- update : [ hashPassword ]
25
+ find : ignoreCaseRegex ,
26
+ create : hashPassword ,
27
+ patch : hashPassword ,
28
+ update : hashPassword
20
29
}
21
30
} ;
22
31
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import service from 'feathers-mongoose';
3
3
import Model from '../../models/users/user.model' ;
4
4
import hooks from './users.hooks' ;
5
5
6
- const UserService = service ( { Model } ) ;
6
+ const UserService = service ( { Model, whitelist : [ '$options' , '$regex' ] } ) ;
7
7
8
8
export default ( app : Application ) : void => {
9
9
app . use ( '/users' , UserService ) ;
You can’t perform that action at this time.
0 commit comments