class staticbo.commonRules. IsInAnyRoleRule
Source: common-rules/
The rule ensures that the user is member of a role from a group.
Properties
new IsInAnyRoleRule(action[, target], roles, message[, priority][, stopsProcessing])
Creates a new is-in-any-role rule object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
action |
|
The action to be authorized. |
|
target |
(bo.shared.PropertyInfo, string, or null) |
Yes |
Eventual parameter of the authorization action. |
roles |
Array of string |
|
The names of the roles the user can be member of. |
message |
string |
|
Human-readable description of the rule failure. |
priority |
number |
Yes |
The priority of the rule. |
stopsProcessing |
boolean |
Yes |
Indicates the rule behavior in case of failure. |
- Extends
- bo.rules.AuthorizationRule
- Throws
-
Argument error: The action must be a AuthorizationAction item.
-
Argument error: The target must be a PropertyInfo object in case of property read or write.
-
Argument error: The target must be a non-empty string in case of method execution.
-
Argument error: The target must be null in case of model actions.
-
Argument error: The roles must be an array of string values.
-
Argument error: The message must be a non-empty string.
Properties
noAccessBehavior bo.rules.NoAccessBehavior
The action to do when the rule fails.
- Inherited from
- bo.rules.AuthorizationRule#noAccessBehavior
read-onlyroles
Array of string
The names of the roles the user can be member of.
read-onlyruleName
string
The name of the rule type. The default value usually the name of the constructor, without the Rule suffix.
- Inherited from
- bo.rules.RuleBase#ruleName
Methods
abstractexecute(userInfo) → (bo.rules.AuthorizationResult or undefined)
Checks if the user is member of a role from the defined group.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
userInfo |
|
Information about the current user. |
- Returns
-
(bo.rules.AuthorizationResult or undefined)
Information about the failure.
initialize(action[, target], message[, priority][, stopsProcessing])
Sets the properties of the rule.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
action |
|
|
The action to be authorized. |
target |
|
Yes |
Eventual parameter of the authorization action. |
message |
|
|
Human-readable description of the rule failure. |
priority |
|
Yes |
The priority of the rule. |
stopsProcessing |
|
Yes |
Indicates the rule behavior in case of failure. |
- Inherited from
- bo.rules.AuthorizationRule#initialize
- Throws
-
Argument error: The action must be a AuthorizationAction item.
-
Argument error: The target must be a PropertyInfo object in case of property read or write.
-
Argument error: The target must be a non-empty string in case of method execution.
-
Argument error: The target must be null in case of model actions.
-
Argument error: The message must be a non-empty string.
result([message], severity) → bo.rules.AuthorizationResult
Returns the result of the rule executed. If the rule fails and the noAccessBehavior property is bo.rules.NoAccessBehavior#throwError, throws an authorization error.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
|
Yes |
Human-readable description of the rule failure. |
severity |
|
|
The severity of the failed rule. |
- Inherited from
- bo.rules.AuthorizationRule#result
- Throws
-
Authorization error: The user has no permission to execute the action.
- Returns
-
The result of the authorization rule.