angela
7 years agoCatalyst II
Check if user has certain permissions in client side Method
Hi,
I created a custom Action in ItemType 'Part' that calls a client Method. Only the Part Owner shall be able to run the Action.
The Owner can be one person or a user group. How can I check, if the current user is in this user group and have the necessary permissions to run the Action?
I tried the following AML query, but unfortunately no Result is returned:
// check permission
var aml = "<AML><Item type = \"Part\" id=\"7FB48EA1AFAC4DA498F7AA4E531A7828\" access_type=\"can_update\" action=\"getPermissions\" ></Item></AML>";
var result = inn.applyAML(aml);
return alert(result.getResult() );
In a server side Method I can use the following code:
string ownedById = this.getProperty("owned_by_id");
if (!CCO.Permissions.IdentityListHasId(Aras.Server.Security.Permissions.Current.IdentitiesList, ownedById))
{
return inn.newError("Not allowed.");
}
Is something similar available for client side Methods?
Thanks for your help!
Angela- Hi, you can use this:
function pb_isCurrUserMemberOfIdentityId(identity_to_check) { if (identity_to_check === "") {return false;} var sessionIdentitites_array = top.aras.getIdentityList().split(","); // now we have all identities the current user (session) is member of // scan if given identity is in the list - if yes, return true for (var i=0;i<sessionIdentitites_array.length;i++) { if (identity_to_check == sessionIdentitites_array) {return true;} } return false; };