8000 `hook.app` is undefined in Event filters · Issue #405 · feathersjs/feathers · GitHub
[go: up one dir, main page]

Skip to content

hook.app is undefined in Event filters #405

@sscaff1

Description

@sscaff1

I'm using sequelize. Here is an example scenario of when I need to use this functionality. I have users in groups. When users send a message, I need to see if they are part of that group before allowing them to see the data. GroupUsers is a mapping table mapping groups to users.

My event filter is below. If you console.log(hook.app), it logs undefined.

export default function () {
  return function filterGroupId(data, connection, hook) {
    const query = {
      userId: connection.user.id,
      groupId: data.groupId,
      deleted: false,
    };
    return hook.app.service('groupUsers').find({ query })
    .then(result => {
      if (result.total > 0) {
        return data;
      }
      return false;
    });
  };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0