You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
This is the expected behavior. Beforefind is not designed to run queries but to alter an incoming query. Note that you could use a matchesQuery or matchesKeyInQuery in order to filter the inbox
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
The text was updated successfully, but these errors were encountered: