How to set Server code acl permissions

This forum contains topics that were moved from Get Satisfaction
Mark7294305
Posts: 0
Joined: Fri Dec 26, 2014 2:10 am

How to set Server code acl permissions

Post by Mark7294305 »

Hello Support
I have created an app with a database. The Database Items are created or updated by users using the database create and update rest services or by a server code script I created. The problem I am having is whenever a user creates and saves an item into the database, the same user cannot update the same item using the server code script I created. the problem is to with the acl permissions. On the database I set the default permission to @creator. on the database create and update rest services and deleted the default acl "*" and I set the permission using JS

var acl = {};

acl[value] = {"read": true, "write": false};

return acl;

But I do not know how to set the acl permission on the server code script. My script says

var DB_id = "*";
var collectionName = "
";
var UserSessionToken = request.get("UserSessionToken");

query = Collection.query(DB_id, collectionName, params, UserSessionToken);

Code: Select all

  if (query.length === 0) 

 {  

   Collection.createObject(DB_id, collectionName,  { 

     "column1": "1", 
     "acl": //what do I enter here? 
 }); 
 } 

else  
 { 

   for (var keym = 0; keym < query.length; keym++) { 
     var currentObject = query[keym]; 

     Collection.updateObject(DB_id, collectionName, UserSessionToken,  currentObject["_id"], { 
       "column1": "101", 
       "acl": //what do I enter here? 

});

Code: Select all

   }} 

Please help

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

How to set Server code acl permissions

Post by Serhii Kulibaba »

Hello Mark,

You have to send user's Id to the server code and use it as the request parameter.

Mark7294305
Posts: 0
Joined: Fri Dec 26, 2014 2:10 am

How to set Server code acl permissions

Post by Mark7294305 »

Hi Segiy
Could you give me an example of what it should look like?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to set Server code acl permissions

Post by Alena Prykhodko »

Post Reply