Writing A cloud parsing function (which uses the Parse Javascript SDK ), and I am having trouble checking if the current user has the "Admin" role. I am viewing a web view of the Role class and a role with the name "Admin" exists, if I click "View Relations" for users, it shows the current user. I doubt it matters, but "Admin" is the only role, and the current user is the only user with the role. Finally, the Administrator role has a public read ACL, so this should not cause any problems either.
The code is as follows:
...
var queryRole = new Parse.Query(Parse.Role);
queryRole.equalTo('name', 'Admin');
queryRole.equalTo("users", Parse.User.current());
queryRole.first({
success: function(result) {
var role = result;
role ? authorized = true : console.log('Shiet, user not Admin');
},
error: function(error) {
console.log("Bruh, queryRole error");
}
})
console.log('After test: Auth = ' + authorized);
if (!authorized) {
response.error("You ain't no admin, measly user");
return;
}
...
This leads to the following in the log:
: Auth = false
: Auth = false