Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hook.app is undefined in Event filters #405

Closed
sscaff1 opened this issue Sep 13, 2016 · 6 comments
Closed

hook.app is undefined in Event filters #405

sscaff1 opened this issue Sep 13, 2016 · 6 comments

Comments

@sscaff1
Copy link
Contributor

sscaff1 commented Sep 13, 2016

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;
    });
  };
}
@kaiquewdev
Copy link

Your service was using this hook, i mean calling it?

@sscaff1
Copy link
Contributor Author

sscaff1 commented Sep 13, 2016

Yea I have a few before and after hooks running fine before this filter happens.

@kaiquewdev
Copy link

Solving that issue with an member of the core development team.

#406

@sscaff1
Copy link
Contributor Author

sscaff1 commented Sep 13, 2016

Awesome thank you.

@daffl
Copy link
Member

daffl commented Sep 15, 2016

Closed via #406

@lock
Copy link

lock bot commented Feb 7, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants