Changing data in another PFuser object

前端 未结 3 974
南旧
南旧 2021-01-06 00:28

In my game, a user can cause damage to another user, and take some of their gold. The gold variable is stored in the other users PFUser object. How can one user change the v

3条回答
  •  感情败类
    2021-01-06 00:44

    The best solution would be to handle it with a cloud code. Manipulating a non authenticated PFUser object from client side will raise some security issues. Have a cloud function like:

      Parse.Cloud.define("stealGold", function(request, response) {
        var query = new Parse.Query(Parse.User);
        query.equalTo("objectId", request.params.targetObjectId);
        query.find({useMasterKey : true}).then(function(results) {
        // process the result of the query here
        // Save the user object
    
        });
      });
    

    You may read about it in docs here: https://parse.com/docs/data#security-cloudcode

提交回复
热议问题