feathersjs-ecosystem/feathers-authentication-hooks

setField not work at hook while defining custom service method (using feathers generate app)

Closed this issue · 1 comments

Steps to reproduce

  1. Use feathers generate app to create the boilerplate.
  2. Generate the service. e.g. feathers g messages
  3. In the message model, associate the user model.
    messages.belongsTo(models.users);
  4. Add some users
  5. Add some messages. Some belong to user A, some belong to user B.
  6. in messages.hooks.js, add the hook on the "before" scope:
    get: [
        setField({
            from: 'params.user.id',
            as: 'params.query.userId'
        })
    ]
  1. Customize the get method in messages.classs.js like this:
    async get(id, params) {
        params.query = { // just empty is ok
            // $select: []
        };
        return super.get(id, params);
    }

  1. Sign in to get the user token
  2. Try to query own and other users' messages.

Expected behavior

Only the user own messages are authorized to access. Others cannot.

Actual behavior

All others messages can be "GET". If taking out the params.query = { }, the hook is functional.

System configuration

Last version of Node.js and feathers stuff.

What's wrong with this?

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.