Description
For implementation related questions or technical support, please refer to the stackoverflow community.
Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!
- [ ✓ ] You've met the prerequisites.
- [ ✓ ] You're running the latest version of Parse Server.
- [ ✓ ] You've searched through existing issues. Chances are that your issue has been reported or resolved before.
Environment Setup
Steps to reproduce
-
Create one user
curl -X POST -H "X-Parse-Application-Id: f15RG3DbyKXrMEVH1u9HVKGuCynEIwy41VnH7Kuw" -H "Content-Type: application/json" -d '{"username":"digbick","password":"qwerty"}' https://fathomless-earth-52600.herokuapp.com/parse/users
Sample output
{"objectId":"hwoH7ADeBo","createdAt":"2016-03-18T10:33:49.770Z","sessionToken":"r:f84be29e1edc20803b203e3d6c9b2e18"}
-
Create a private Settings object for this user using an ACL like
"ACL":{"hwoH7ADeBo":{"read":true,"write":true}}
(note the usage of the session token obtained in step 1)curl -X POST -H "X-Parse-Application-Id: f15RG3DbyKXrMEVH1u9HVKGuCynEIwy41VnH7Kuw" -H "X-Parse-Session-Token: r:f84be29e1edc20803b203e3d6c9b2e18" -H "Content-Type: application/json" -d '{"user":{"__type":"Pointer","className":"_User","objectId":"hwoH7ADeBo"}, "saveOriginalPhotos":true, "ACL":{"hwoH7ADeBo":{"read":true,"write":true}}}' https://fathomless-earth-52600.herokuapp.com/parse/classes/Settings
-
Fetch all Settings objects (using the session token again)
curl -X GET -H "X-Parse-Application-Id: f15RG3DbyKXrMEVH1u9HVKGuCynEIwy41VnH7Kuw" -H "X-Parse-Session-Token: r:f84be29e1edc20803b203e3d6c9b2e18" -H "Content-Type: application/json" -d '{}' https://fathomless-earth-52600.herokuapp.com/parse/classes/Settings
Expect an output as follows
{"results":[{"ACL":{"hwoH7ADeBo":{"read":true,"write":true}},"objectId":"ZFrrUgrgaR","user":{"__type":"Pointer","className":"_User","objectId":"hwoH7ADeBo"},"saveOriginalPhotos":true,"updatedAt":"2016-03-18T10:36:45.017Z","createdAt":"2016-03-18T10:36:45.017Z"}]}
And also, if you fetch all Settings without the session token, that is
curl -X GET -H "X-Parse-Application-Id: f15RG3DbyKXrMEVH1u9HVKGuCynEIwy41VnH7Kuw" -H "Content-Type: application/json" -d '{}' https://fathomless-earth-52600.herokuapp.com/parse/classes/Settings
You should get
{"results":[]}
Which makes sense.
-
Create a cloud function which fetches all Settings and returns them
Parse.Cloud.define('getSettings', function(req, res) { var query = new Parse.Query("Settings"); query.find().then(function(settings) { res.success(settings); }, function(error) { res.error(error); }); });
-
Call the
getSettings
cloud function sending the session token as wellcurl -X POST -H "X-Parse-Application-Id: f15RG3DbyKXrMEVH1u9HVKGuCynEIwy41VnH7Kuw" -H "X-Parse-Session-Token: r:f84be29e1edc20803b203e3d6c9b2e18" -H "Content-Type: application/json" -d '{}' https://fathomless-earth-52600.herokuapp.com/parse/functions/getSettings
It returns nothing
{"result":[]}
That is, the current user is not being taken into account when querying objects in cloud code, and so, all queries behave like we're not logged in.