feathersjs-ecosystem / feathers-authentication-hooks

Useful hooks for authentication and authorization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

queryWithCurrentUser Generating the following error There is no current user to associate.

abalad opened this issue · comments

{
    "name": "GeneralError",
    "message": "There is no current user to associate.",
    "code": 500,
    "className": "general-error",
    "data": {},
    "errors": {}
}
const { authenticate } = require('@feathersjs/authentication').hooks;
const hooks = require('feathers-authentication-hooks');

module.exports = {
  before: {
    all: [],
    find: [
      function(context){ console.log(context) },
      hooks.queryWithCurrentUser({ idField: 'id', as: 'usuario_id' })
    ],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  after: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  },

  error: {
    all: [],
    find: [],
    get: [],
    create: [],
    update: [],
    patch: [],
    remove: []
  }
};

There has to be a params.user, which is usually added by the authenticate() hook.

I've created an implementation suggestion #49