51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
(function(){
|
|
|
|
class LNIdentity
|
|
{
|
|
constructor(src){
|
|
if (!src)
|
|
src = {};
|
|
this.IdentityName = src.IdentityName || "";
|
|
this.UniqueID = src.UniqueID || null;
|
|
this.Roles = src.AssignedRoles || [];
|
|
}
|
|
|
|
findRolesByName(identityName){
|
|
let roleMask = 0;
|
|
this.Roles.forEach(role => {
|
|
if (role.IdentityName == identityName)
|
|
roleMask = role.Roles;
|
|
});
|
|
return roleMask;
|
|
}
|
|
findRolesByID(identityUniqueID){
|
|
let roleMask = 0;
|
|
this.Roles.forEach(role => {
|
|
if (role.UniqueID == identityUniqueID)
|
|
roleMask = role.Roles;
|
|
});
|
|
return roleMask;;
|
|
}
|
|
|
|
hasRole(role,identityName){
|
|
let roles = this.findRolesByName(identityName);
|
|
return (roles & role) == role;
|
|
}
|
|
|
|
}
|
|
|
|
LNIdentity.VIEW = (1<<0);
|
|
LNIdentity.USE = LNIdentity.VIEW | (1<<1);
|
|
LNIdentity.CONTROL = LNIdentity.VIEW | (1<<2);
|
|
LNIdentity.MANAGE = LNIdentity.CONTROL | (1<<3);
|
|
LNIdentity.ADMIN = 0x0000FFFF;
|
|
|
|
LNIdentity.MANAGEROLES = (1<<16);
|
|
|
|
LNIdentity.IMPERSONATE = (1<<24);
|
|
LNIdentity.OWN = 0x0FFFFFFF;
|
|
LNIdentity.BE = 0x0000FFFF;
|
|
LNIdentity.SUPER = 0x7FFFFFFF;
|
|
|
|
LN.$add("LN.Identity",LNIdentity);
|
|
})(); |