class staticbo.rules. AuthorizationRule
Source: rules/
Represents an authorization rule.
Properties
new AuthorizationRule(ruleName)
Creates a new authorization rule object. The rule instances should be frozen.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
ruleName |
string |
|
The name of the rule. It is typically the name of the constructor, without the Rule suffix. |
- Extends
- bo.rules.RuleBase
- Throws
-
Argument error: The rule name must be a non-empty string.
Properties
noAccessBehavior bo.rules.NoAccessBehavior
The action to do when the rule fails.
read-onlyruleId
string
The identifier of the authorization action. Generally it is the action value, or when target is not empty, the action value and the target name separated by a dot, respectively.
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
initialize(action[, target], message[, priority][, stopsProcessing])
Sets the properties of the rule.
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. |
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. |
- 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 |
string |
Yes |
Human-readable description of the rule failure. |
severity |
|
The severity of the failed rule. |
- Throws
-
Authorization error: The user has no permission to execute the action.
- Returns
-
bo.rules.AuthorizationResult
The result of the authorization rule.