I have a Cloud Code function that is being called by users. In that function, I create a new object, "Invitation", which triggers a before_save handler when saving.
Since a user is running the Cloud Code function, I would expect request.user in the before_save function to be the same, but it appears to be saving the Invitation object as master, resulting in request.user being null.
Parse.Cloud.define("sendInvite", function(request, response) {
var invitation = new Invitation();
invitation.save().then(function(invitation){
response.success();
}, function(error){
response.error(error);
});
});
Parse.Cloud.beforeSave("Invitation", function(request, response) {
var sender = request.user;
// sender is null, since master key is being used...
});
This doesn't seem like correct behaviour – the cloud code function shouldn't default to executing using the master key unless explicitly told to do so.
Any thoughts?