parse-server: Query for Parse.User is empty when calling 2nd time

Environment Setup

Parse Server 2.2.2 Using Parse JS SDK

Steps to reproduce

I’m setting an ACL for every user that is saved in an afterSave Hook:

Parse.Cloud.afterSave('_User', function(request, response) {
  // Use the masterkey
  Parse.Cloud.useMasterKey();
  // Get the user
  var user = request.object;
  // Create an ACL
  var userACL = new Parse.ACL();
  userACL.setPublicReadAccess(false);
  userACL.setReadAccess(user, true);
  userACL.setWriteAccess(user, true);
  userACL.setRoleWriteAccess("admin", true);
  userACL.setRoleReadAccess("admin", true);
  // Set the ACL to the user
  user.setACL(userACL);
  // Save the user
  user.save()...

This should now allow only the user itself or and admin user to read/write the user object. When I now query for ALL users as and admin like this:

    let query = new Parse.Query(Parse.User);
    query.ascending('username');
    query.find().then(users => {
      this.users = users;
      console.log(this.users);
    }, error => {
      console.log('Error: ' + error.code + ' ' + error.message);
    });

I get a list of all users. But when I run the same query a second time, it is empty.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (11 by maintainers)

Most upvoted comments

Oh, this is already fixed in the master branch of the JS SDK. I’m just waiting on others to fix the issues with RN and the new LiveQueries interface before releasing 1.8.2.

@hramos I already did the test against the REST API (see my curl example above) and there everything worked correct. So I guess this is an issue with the JS SDK. As far as I could debug I assume the JS SDK has problems when the result of a query for Parse.User contains the currently logged in user itself.

I just did a test for the same query using a standard curl request:

curl -X GET -H "X-Parse-Application-Id: myapp" -H "X-Parse-Session-Token: r:63fe72cfbb93cb1de49547e0dccaed0b" -H "Cache-Control: no-cache" "http://localhost:1337/api/classes/_User"

Where the session token is the one that my admin user got in the webapp. This request is always returning the correct user list. So I guess this could be an issue with the JS SDK…