File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change 1
1
import { HookContext } from '@feathersjs/feathers' ;
2
2
3
3
export default async ( context : HookContext ) : Promise < boolean > => {
4
- console . log ( context . params . authenticated ) ;
5
4
return context . params . authenticated || false ;
6
5
} ;
7
6
Original file line number Diff line number Diff line change 1
1
import { Application } from '@feathersjs/express' ;
2
+ import { Params } from '@feathersjs/feathers' ;
2
3
import { Poll } from 'which-types' ;
3
4
4
5
5
6
export default class Profiles {
6
7
app ! : Application ;
7
8
8
- async get ( id : string ) : Promise < Poll [ ] > {
9
+ async get ( id : string , params : Params ) : Promise < Poll [ ] > {
9
10
return this . app . service ( 'polls' ) . find ( {
11
+ ...params ,
10
12
query : {
11
13
authorId : id
12
14
}
Original file line number Diff line number Diff line change
1
+ import _ from 'lodash' ;
1
2
import { hooks } from '@feathersjs/authentication-local' ;
3
+ import { discard } from 'feathers-hooks-common' ;
2
4
import { HookContext } from '@feathersjs/feathers' ;
3
5
4
6
const hashPassword = hooks . hashPassword ( 'password' ) ;
5
7
6
- const localDispatch = async ( context : HookContext ) : Promise < HookContext > => {
7
- context . result = context . dispatch ;
8
+ const ignoreCaseRegex = async ( context : HookContext ) : Promise < HookContext > => {
9
+ context . params . query = _ . mapValues ( context . params . query , data => {
10
+ return _ . set ( data , '$options' , 'i' ) ;
11
+ } ) ;
8
12
return context ;
9
13
} ;
10
14
11
15
export default {
12
16
after : {
13
- all : [ hooks . protect ( 'password' ) ] ,
14
- get : [ localDispatch ] // Protect password from local get's
17
+ all : hooks . protect ( 'password' ) ,
18
+ get : discard ( 'password' ) // Protect password from local get's
15
19
} ,
16
20
before : {
17
- create : [ hashPassword ] ,
18
- patch : [ hashPassword ] ,
19
- update : [ hashPassword ]
21
+ find : ignoreCaseRegex ,
22
+ create : hashPassword ,
23
+ patch : hashPassword ,
24
+ update : hashPassword
20
25
}
21
26
} ;
22
27
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