Constructor
new Permission(metadataopt)
Creates a new Permission object, with an empty rule set
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
metadata |
util.Metadata |
<optional> |
The metadata of the object |
- Source:
Members
_metadata :util.Metadata
Type:
- Source:
rules :Object.<string, string>
Type:
- Object.<string, string>
- Source:
Methods
(static) fromJSON(json) → {util.Permission}
Creates a permission from the given rules.
Parameters:
Name | Type | Description |
---|---|---|
json |
json | The rules. |
- Source:
Returns:
The permission.
- Type
- util.Permission
allowAccess(…userOrRole) → {util.Permission}
Allows the given users or rules to perform the operation
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userOrRole |
model.User | model.Role | string |
<repeatable> |
The users or roles to allow |
- Source:
Returns:
this permission object
- Type
- util.Permission
allRules() → {Array.<string>}
Returns a list of user and role references of all rules
- Source:
Returns:
a list of references
- Type
- Array.<string>
clear() → {void}
Removes all rules from this permission object
- Source:
Returns:
- Type
- void
copy(permission) → {util.Permission}
Copies permissions from another permission object
Parameters:
Name | Type | Description |
---|---|---|
permission |
util.Permission | The permission to copy from |
- Source:
Returns:
- Type
- util.Permission
deleteAccess(…userOrRole) → {util.Permission}
Deletes any allow/deny rules for the given users or roles
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userOrRole |
model.User | model.Role | string |
<repeatable> |
The users or roles to delete rules for |
- Source:
Returns:
this permission object
- Type
- util.Permission
denyAccess(…userOrRole) → {util.Permission}
Denies the given users or rules to perform the operation
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userOrRole |
model.User | model.Role | string |
<repeatable> |
The users or roles to deny |
- Source:
Returns:
this permission object
- Type
- util.Permission
fromJSON(json) → {void}
Sets the permission rules from json
Parameters:
Name | Type | Description |
---|---|---|
json |
json | The permission json representation |
- Source:
Returns:
- Type
- void
getRule(userOrRole) → {string}
Returns the actual rule of the given user or role.
Parameters:
Name | Type | Description |
---|---|---|
userOrRole |
model.User | model.Role | string | The user or role to check for |
- Source:
Returns:
The actual access rule or undefined if no rule was found
- Type
- string
isAllowed(userOrRole) → {boolean}
Checks whenever the user or role is explicit allowed to perform the operation.
Parameters:
Name | Type | Description |
---|---|---|
userOrRole |
model.User | model.Role | string | The user or role to check for |
- Source:
Returns:
true
If the given user or role is allowed
- Type
- boolean
isDenied(userOrRole) → {boolean}
Checks whenever the user or role is explicit denied to perform the operation.
Parameters:
Name | Type | Description |
---|---|---|
userOrRole |
model.User | model.Role | string | The user or role to check for |
- Source:
Returns:
true
If the given user or role is denied
- Type
- boolean
isPublicAllowed() → {boolean}
Gets whenever all users and roles have the permission to perform the operation
- Source:
Returns:
true
If public access is allowed
- Type
- boolean
setPublicAllowed() → {void}
Sets whenever all users and roles should have the permission to perform the operation
Note: All other allow rules will be removed.
- Source:
Returns:
- Type
- void
toJSON() → {json}
A Json representation of the set of rules
- Source:
Returns:
- Type
- json