Peter Perecz
Posts: 0
Joined: Sun Feb 01, 2015 9:02 pm

ACL for multiple users in Ionic

Hi there,

Could you help me with the following;
I am using Ionic framework, which is fantastic. Utilizing your tutorial I could also manage to set ACL for one user, but I am really struggling to achieve the same for more users.

I want to achieve that a group of users can have RW access to certain items while other only could Read.

I defined those users in two arrays like

var usersRW = ["55a3b331e4b0b40eb78833c1","55a3b300e4b0b40eb78833b8","55a3b296e4b0f840f33a1b00"];
var useronlyR = ["55a3ab50e4b0b40eb7883285","55a3ab3ae4b0b40eb788327e"];

Could you pls let me know what and how shell be done at invoking the Create service?

Thanks in advance,
Peter

Pavel Zarudniy
Posts: 0
Joined: Mon Jul 06, 2015 8:56 am

ACL for multiple users in Ionic

Hi Peter,
Unfortunately it is not clear enough.
Could you please provide more details, screen shots would also help.

Peter Perecz
Posts: 0
Joined: Sun Feb 01, 2015 9:02 pm

ACL for multiple users in Ionic

Hello Pavel,

Thanks for coming back.

What I try to achieve is the following - and I am not sure if it is possible to do so and how if so.

Let's assume I have a collection called myDB with one field e.g text.

I have an array called usersRW. This array contains userID of the ones, who will have read&write access to all "text" in myDB. (e.g. var usersRW = ["55a3b331e4b0b40eb78833c1","55a3b300e4b0b40eb78833b8","55a3b296e4b0f840f33a1b00"]; )

I have an other array called useronlyR. This one contains userIDs of the ones, who will have only read access to all "text" in myDB. (e.g. var useronlyR = ["55a3ab50e4b0b40eb7883285","55a3ab3ae4b0b40eb788327e"]; )

I thought there is a way to set ACL like following when calling a create service for the myDB collection like this;

{
"*":{},
"55a3b331e4b0b40eb78833c1":{"read":true,"write":true},
"55a3b300e4b0b40eb78833b8":{"read":true,"write":true},
"55a3b296e4b0f840f33a1b00":{"read":true,"write":true},
"55a3ab50e4b0b40eb7883285":{"read":true,"write":false},
"55a3ab3ae4b0b40eb788327e":{"read":true,"write":false}
}

resulting this as on the attached pic;

I hope I could express myself better.

Thanks,
Peter
Image

Peter Perecz
Posts: 0
Joined: Sun Feb 01, 2015 9:02 pm

ACL for multiple users in Ionic

I guess I am looking for an Ionic/Angular alternative of this;
https://getsatisfaction.com/apperyio/...

Thx
Peter

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

ACL for multiple users in Ionic

Hello Peter,

Sorry for the radio silence here.
To do this you should fill request data before calling the create service. The code should be similar to this one:
precodevar requestData = {};
requestData.data = Apperyio.EntityAPI('some_service.request.body', undefined, true);
$scope.readUsers = ["id1", "id2"];
$scope.writeUsers = ["id3", "id4"];

readUsers.forEach(function(userId) {

Code: Select all

 $scope.acl[userId] = {"read":true, "write": false}; 

});
writeUsers.forEach(function(userId) {

Code: Select all

 $scope.acl[userId] = {"read":true, "write": true}; 

});

requestData.data.acl = $scope.acl;

Apperyio.get("some_service")(requestData).then(

Code: Select all

 function(success) { 

 }, 

 function(error) { 

 });/code/pre 

This is the code of creation function, and this approach is better then using the mapping.

Peter Perecz
Posts: 0
Joined: Sun Feb 01, 2015 9:02 pm

ACL for multiple users in Ionic

Hello Evgene,

Based on your inputs the following worked for me. (Array of read and write users can be edited on the usual way.)

$scope.readUsers[0] = $scope.userid;

for (i = 0; i < $scope.readUsers.length; i++) {
// text += cars + "
";

Code: Select all

 $scope.Org_to_Create.acl[$scope.readUsers[i]] = {"read":true, "write": false};    

}

$scope.writeUsers[0] = $scope.userid;
for (i = 0; i < $scope.writeUsers.length; i++) {
// text += cars + "
";

Code: Select all

 $scope.Org_to_Create.acl[$scope.writeUsers[i]] = {"read":true, "write": true};    

}

$scope.Org_to_Create.acl["*"] = {"read":false, "write": false};

Thanks,
Peter

Return to “Issues”