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

Roles (ACL) not working properly #3833

Closed
polo2244 opened this issue May 19, 2017 · 2 comments
Closed

Roles (ACL) not working properly #3833

polo2244 opened this issue May 19, 2017 · 2 comments

Comments

@polo2244
Copy link

Issue Description

Performing this code in the cloud gives an object not found error.
var query = new Parse.Query('classname'); query.get('hVYmCOi7M9').then(function(object) { ...

---Details----
I have a User (a7MTQFYXA9) belonging to a role (admins).
and object (hVYmCOi7M9) with ACL (r/w to admins role).
I have a cloud function (templateTest) that takes an objectId (in our test case hVYmCOi7M9) from ios SDK and retrieves this object, and returns a response of the task to be completed.

ROLE
screen shot 2017-05-19 at 5 48 34 pm

ROLE USERS
screen shot 2017-05-19 at 5 48 52 pm

OBJECT
screen shot 2017-05-19 at 5 49 32 pm

OBJECT ACL
screen shot 2017-05-19 at 5 49 27 pm

Note:
Not restricting the ACL of the object to the role and adding (public read) retrieves the object with no errors. So this may be an Role thing bug

Steps to reproduce

Please read the explanation above.

Expected Results

Object to be retrieved successfully.

Actual Outcome

Error object not found

Environment Setup

  • Server

    • parse-server version 2.4.0
    • Operating System: Mac
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? Localhost
  • Database

    • MongoDB version: 3.4.3
    • Storage engine: Default (GridStore)
    • Hardware: [FILL THIS OUT]
    • Localhost or remote server? Localhost

Logs/Trace

error: Failed running cloud function templateTest for user a7MTQFYXA9 with: Input: {"theObjectId":"hVYmCOi7M9"} Error: {"code":141,"message":{"code":101,"message":"Object not found."}}

@polo2244 polo2244 changed the title Roles not working properly Roles (ACL) not working properly May 19, 2017
@polo2244
Copy link
Author

This works in iOS
PFQuery* query = [PFQuery queryWithClassName:@"classname"]; [query getObjectInBackgroundWithId:@"hVYmCOi7M9" block:^(PFObject* object, NSError* error{ }];
The problem may just be in cloud code.

@flovilmart
Copy link
Contributor

you have to pass the sessionToken of the user making the request:

Parse.Cloud.define('func', (req, res) => {
  const sessionToken = req.user.getSessionToken()
  let query = new Parse.Query("...");
  query.get("objectId", {sessionToken: sessionToken}).then(...)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants