sreenivas
sreenivas

Reputation: 2257

Get user info from ACL in parse cloud code

I am trying to get user info from the ACL in cloud code.

console.log(request.object.getACL())

returns me this...

{"JEuS4iJ7lE":{"read":true},"MVrr5lrUwc":{"read":true,"write":true}}

How to get the user info from the above user objectId.

Upvotes: 1

Views: 871

Answers (2)

kautenja
kautenja

Reputation: 140

Though this thread is super old, I'm sure this is how you would accomplish what you're looking for.

var ids = [];
var permissions = request.object.getACL().permissionsById;
for (var id in permissions) {
    ids.push(id);
}

That would give you an array of all the ids that have an ACL registered with the object that you can then use to query, etc. you can even refine it a little i.e.

var ids = [];
var permissions = request.object.getACL().permissionsById;
for (var id in permissions) {
    if (id.read != true) {
        return;
    }
    ids.push(id);
}

to get only users with read permission.

Upvotes: 2

Serhii Hordiichuk
Serhii Hordiichuk

Reputation: 1

Please try this variant:

request.object.getACL().permissionsById[*userId*]

Upvotes: -1

Related Questions