Class: Role

Role

new Role(rbac, name, add, cb)

Role constructor
Name Type Default Description
rbac RBAC Instance of the RBAC
name String Name of the role
add Boolean true optional True if you need to save it to storage
cb function Callback function after add

Extends

Members

nameString

Get name of actual instance

rbacRBAC null

Get instance of RBAC

Methods

can(action, resource, cb){Role}

Return true if contains permission
Name Type Description
action String Name of action
resource String Name of resource
cb function Callback function
Returns:
current instance of role

canAll(permissions, cb){Role}

Check if the model has all of the given permissions
Name Type Description
permissions Array List of permissions. Each has structure (String action, String resource)
cb function Callback function
Returns:
current instance of role

canAny(permissions, cb){Role}

Check if the role has any of the given permissions
Name Type Description
permissions Array List of permissions. Each has structure (String action, String resource)
cb function Callback function
Returns:
current instance of role

getScope(cb){Role}

Return array of permission assigned to actual role
Name Type Description
cb function Callback function
Returns:
current instance of role

grant(item, cb){Role}

Add role or permission to current role
Name Type Description
item Role | Permission Instance of role or permission
cb function Callback function
Returns:
current instance of role

hasRole(roleChildName, cb){Role}

Return true if the current role contains the specified role name
Name Type Description
roleChildName String Name of role
cb function Callback function
Returns:
current instance of role

inherited remove(cb){Base}

Remove this from RBAC (storage)
Name Type Description
cb function Callback function

revoke(item, cb){Role}

Remove role or permission from current role
Name Type Description
item Role | Permission Instance of role or permission
cb function Callback function
Returns:
current instance of role