class staticbo.commonRules. IsInRoleRule
Source: common-rules/
The rule ensures that the user is member of a role.
Properties
new IsInRoleRule(action[, target], role, message[, priority][, stopsProcessing])
Creates a new is-in-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. |
role |
string |
|
The name of the role the user is 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 role must be a non-empty string.
-
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-onlyrole
string
The name of the role the user is 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 the defined role.
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.