问题描述
我对在用户对象上的afterSave方法中获取的无效会话令牌有疑问.我实际上在Parse云代码中的beforeSave和afterSave中运行相同的查询,而beforeSave中的一个则有效,而afterSave中的一个则不可行.我想知道关于Parse的工作方式我是否不了解,因为我在afterSave方法中得到了无效的会话令牌,而在beforeSave方法中没有问题.
I have a question regarding an invalid session token that I am getting in an afterSave method on a user object. I literally run the same query in the beforeSave and the afterSave in Parse cloud code and the one in the before save works while the one in the afterSave does not. I was wondering if there is something that I am not understanding in regards to how Parse works in that I am getting an invalid session token in the afterSave method but no problems in the beforeSave method.
这是查询...
var AccessCode = Parse.Object.extend("AccessCode");
var query = new Parse.Query(AccessCode);
query.equalTo("code", accessCode);
query.notEqualTo("isUsed", true);
query.find({
success: function(results) {
//do some things
},
error: function(error) {
//display the error
}
})
推荐答案
我通过稍微更改代码来解决了这个问题...
I solved this problem by changing the code a little bit...
Parse.Cloud.useMasterKey();
var query = new Parse.Query("AccessCode");
query.equalTo("code", accessCode);
query.notEqualTo("isUsed", true);
query.find({
success: function(results) {
//do some things
},
error: function(error) {
//display the error
}
})
现在一切正常,但我仍然不确定为什么一开始它们都不起作用.
All works fine an dandy now, but I am still unsure why it all didn't work in the first place.
这篇关于无效的会话错误解析AfterSave在用户中的云代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!