diff options
Diffstat (limited to 'services')
| -rw-r--r-- | services/profiles/profiles.class.ts | 4 | ||||
| -rw-r--r-- | services/users/users.hooks.ts | 19 | ||||
| -rw-r--r-- | services/users/users.service.ts | 2 | 
3 files changed, 16 insertions, 9 deletions
diff --git a/services/profiles/profiles.class.ts b/services/profiles/profiles.class.ts index 3461cbc..a6de474 100644 --- a/services/profiles/profiles.class.ts +++ b/services/profiles/profiles.class.ts @@ -1,12 +1,14 @@  import { Application } from '@feathersjs/express'; +import { Params } from '@feathersjs/feathers';  import { Poll } from 'which-types';  export default class Profiles {    app!: Application; -  async get(id: string): Promise<Poll[]> { +  async get(id: string, params: Params): Promise<Poll[]> {      return this.app.service('polls').find({ +      ...params,        query: {          authorId: id        } diff --git a/services/users/users.hooks.ts b/services/users/users.hooks.ts index ee1ae1c..48843be 100644 --- a/services/users/users.hooks.ts +++ b/services/users/users.hooks.ts @@ -1,22 +1,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 localDispatch = async (context: HookContext): Promise<HookContext> => { -  context.result = context.dispatch; +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: [localDispatch] // Protect password from local get's +    all: hooks.protect('password'), +    get: discard('password') // Protect password from local get's    },    before: { -    create: [hashPassword], -    patch: [hashPassword], -    update: [hashPassword] +    find: ignoreCaseRegex, +    create: hashPassword, +    patch: hashPassword, +    update: hashPassword    }  }; diff --git a/services/users/users.service.ts b/services/users/users.service.ts index 08c347d..77eb9fd 100644 --- a/services/users/users.service.ts +++ b/services/users/users.service.ts @@ -3,7 +3,7 @@ import service from 'feathers-mongoose';  import Model from '../../models/users/user.model';  import hooks from './users.hooks'; -const UserService = service({ Model }); +const UserService = service({ Model, whitelist: ['$options', '$regex'] });  export default (app: Application): void => {    app.use('/users', UserService);  |