Class: AuthorizationRule

bo.rules. AuthorizationRule

Represents an authorization rule.

new AuthorizationRule(ruleName)

Creates a new authorization rule object. The rule instances should be frozen.

Parameters:
Name Type Description
ruleName string

The name of the rule. It is typically the name of the constructor, without the Rule suffix.

Throws:
Argument error: The rule name must be a non-empty string.

Extends

Members

<readonly> message :string

Human-readable description of the rule failure.

Type:
  • string
Inherited From:

noAccessBehavior :bo.rules.NoAccessBehavior

The action to do when the rule fails.

Type:

<readonly> priority :number

The priority of the rule. Higher number means higher priority.

Type:
  • number
Inherited From:
Default Value:
  • 10

<readonly> ruleId :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.

Type:
  • string

<readonly> ruleName :string

The name of the rule type. The default value usually the name of the constructor, without the Rule suffix.

Type:
  • string
Inherited From:

<readonly> stopsProcessing :boolean

Indicates whether processing of the rules for a property stops when the rule fails.

Type:
  • boolean
Inherited From:
Default Value:
  • false

Methods

<virtual> execute(inputs)

Abstract method to check if the rule is valid for the property.

Parameters:
Name Type Description
inputs Array.<*>

An array of the values of the required properties.

Inherited From:
Throws:
Not implemented error: The Rule.execute method is not implemented.

initialize(action, target, message, priority, stopsProcessing)

Sets the properties of the rule.

Parameters:
Name Type Argument Default Description
action bo.rules.AuthorizationAction

The action to be authorized.

target bo.shared.PropertyInfo | string | null <optional>

Eventual parameter of the authorization action.

message string

Human-readable description of the rule failure.

priority number <optional>
100

The priority of the rule.

stopsProcessing boolean <optional>
false

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 Argument Description
message string <optional>

Human-readable description of the rule failure.

severity bo.rules.RuleSeverity

The severity of the failed rule.

Throws:
Authorization error: The user has no permission to execute the action.
Returns:

The result of the authorization rule.

Type
bo.rules.AuthorizationResult
If you find bugs or have feature requests, please let us know.

JavaScript business objects ♦ Copyright © 2014-2016 Logikum, Ltd.
Documentation generated by JSDoc 3.2.2 on 2015. December 31. using the DocStrap template.