CloudCode User afterSave requires useMasterKey - why?

淺唱寂寞╮ 提交于 2019-12-24 11:35:03

问题


It woked while ago, but suddenly stopped. Looks like it has something to do with session migration but I don't know why and how to deal with it.

So I've got simple cloud code sample:

Parse.Cloud.define("hello", function(request, response) {
  response.success("Hello world!");
});

It works fine naturally.

And I want to run it from afterSave trigger like this:

Parse.Cloud.afterSave(Parse.User, function(request) {
  Parse.Cloud.run('hello', { test: 'test'}, {
    success: function(success) {
      console.log(' Hello success.');
    },
    error: function(error) {
      console.error(' hello failed.');
      console.error("Got an error " + error.code + " : " + error.message);
    }
  });
});

Everything like parse commanded in docs

But when I save user it produces error:

I2015-08-14T06:33:16.709Z] hello failed.
I2015-08-14T06:33:16.711Z]Got an error 209 : invalid session token

How can it be? Am I doing something wrong?

[EDIT]

putting this at the beginning of afterSave trigger helped:

Parse.Cloud.useMasterKey();

I understand this is kind of root command, omitting all ACL restrictions. Can't see where I crossed such restrictions while running simple Hello World function example.

来源:https://stackoverflow.com/questions/32004227/cloudcode-user-aftersave-requires-usemasterkey-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!