Skip to content

beforeFind is ignoring query returns #4633

Closed
@khalilsarabey

Description

@khalilsarabey

Issue Description

Cloud Code get is ignoring beforeFind query and proceeding anyway

Steps to reproduce

I have an app with a chat feature, I'm using "Inbox" class as a chat room, and I have a "Message" class which contains the messages and each message has a pointer to an inbox.
Now adding ACL to Message class would be disastrous to maintain, since users can join and leave rooms, that way I'll need to modify the ACL of each message, imagine tens of thousands of messages (I'm optimistic!)
Thanks to beforeFind I can do the checking in a very easy and clean way, which is when a user is trying to get messages, I check the inbox id in the request, and I run a query that checks if the user is in this chat room or not. Everything makes sense, but beforeFind is totally ignoring the query and proceeding with fetching the results anyway.
Is it a bug in beforeFind or am I doing something wrong?

Here's the code:

var jsonQuery = request.query.toJSON();
var inbox = new Parse.Query('Inbox');
inbox.get(jsonQuery.where.inbox.objectId)
.then(function(results) {
if(!results) {
throw new Parse.Error(101, 'You can not view these messages');
}
});

Expected Results

I expect to return an error if no results from Inbox query

Actual Outcome

It's proceeding anyway.

Environment Setup

  • Server
    • parse-server version : 2.7.2
    • Operating System: macOS Sierra
    • Hardware: mac pro 2011
    • Localhost or remote server? Local

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