Page 1 of 1

ACL for multiple users in Ionic

Posted: Mon Jul 13, 2015 1:09 pm
by Peter Perecz

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


ACL for multiple users in Ionic

Posted: Mon Jul 13, 2015 3:40 pm
by Pavel Zarudniy

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


ACL for multiple users in Ionic

Posted: Mon Jul 13, 2015 5:07 pm
by Peter Perecz

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


ACL for multiple users in Ionic

Posted: Mon Jul 13, 2015 5:12 pm
by Peter Perecz

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

Thx
Peter


ACL for multiple users in Ionic

Posted: Thu Jul 30, 2015 8:26 am
by Evgene Karachevtsev

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.


ACL for multiple users in Ionic

Posted: Tue Oct 27, 2015 2:21 pm
by Peter Perecz

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