Closed

Description
Okay I wrote a cloud function when using the parse dashboard which worked fine. We then switched to a parse server on heroku. The following code works up until it hits Parse.Relation(role, 'users'). The admins.first() runs the success function but with no users returned. I'm 100% positive it's connected to the correct DB and there are users with the 'admin' role, and I am querying a user with 'admin' role, but it's not finding it and returns undefined. Is this an issue with the new Parse server setup?
Parse.Cloud.define('isAdmin', function(req, response){
Parse.Cloud.useMasterKey();
if(!req.params.username){
response.error('no username');
}
var queryRole = new Parse.Query(Parse.Role);
queryRole.equalTo('name','admin');
queryRole.first({
success: function(promise){
var role = promise;
var relation = new Parse.Relation(role, 'users');
var admins = relation.query();
admins.equalTo('username', req.user.get('username'));
admins.first({
success: function(u){
var user = u;
if(user) {
response.success('User is admin')
}
else {
response.error('User is not Admin')
}
},
error: function(){
response.error('Error on user lookup')
}
})
},
error: function(){
response.error('Error on role lookup')
}
})
})
Metadata
Metadata
Assignees
Labels
No labels