Joni de Campos
Posts: 0
Joined: Fri Dec 11, 2015 12:21 pm

How do I add an additional user permissions to ACl using javascript ?

/when we register a new user using the signup service the USER collection have in the ACL column the new user ID with the permission to read and write.

I need that the administrator of the system I am developing to be also be able to read and write.

Do I have to read the ACL value of the new user first or I can just add the ACL with the administrator ID to make it work ?

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

How do I add an additional user permissions to ACl using javascript ?

Hello Joni,

Please add an ID of the administrator for new items, and change ACL value with administrator's account or with a Server Code API, using master key

Joni de Campos
Posts: 0
Joined: Fri Dec 11, 2015 12:21 pm

How do I add an additional user permissions to ACl using javascript ?

Ok...I will give a try and return with the results.

Joni de Campos
Posts: 0
Joined: Fri Dec 11, 2015 12:21 pm

How do I add an additional user permissions to ACl using javascript ?

Hi Sergiy ,

I manage to make it work:

For the Signup Service

// include an acl parameter in the Signup Service
// include this code in the Before Send Event Mapping ind the js for the acl parameter
//admin_ID is the _id of the Administrator System User. You can get it when you make the login of the system
//set read and write permissions for the Administrator

var acl = {};

//set Admin user permission
acl[admin_ID] = {
"read": true,
"write": true
};

acl['*'] = {
"read": true
};

return acl; // return the acl to the service with the admin_ID set with an permission so we can later update the record.

As a response we get the new created user ID ( _id)
Save this ID in a localStorage Variable.

Then create an updateUserService and update only the acl parameter in the user record.

For the updateUserService you created

//Put the bellow js code in the acl paramater in the Before Send Event of the update service Mapping
//Map the resource_ID localStorage to the acl parameter.

var acl = {};

//set resource_ID permission

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

//set Admin user permission. Include the logged admin user _id admin_ID

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

acl['*'] = {
"read": true
};

return acl;

I am still testing this. So if I find any problem I will return to the subject.

Galyna Abramovych
Site Admin
Posts: 84
Joined: Tue Mar 22, 2016 6:03 pm

How do I add an additional user permissions to ACl using javascript ?

Hello Joni,

Thank you for this update!

Return to “Issues”