Module: Assistant::EmployeeToolAuthorization

Defined in:
app/services/assistant/employee_tool_authorization.rb

Overview

Central authorization boundary for Sunny tools that operate as an employee.

Tool builders still choose the exact action and resource they expose; this
helper keeps the active-account and CRM ability checks consistent.

Class Method Summary collapse

Class Method Details

.allowed?(account, action, resource) ⇒ Boolean

Checks whether an active employee account may perform an action.

Parameters:

  • account (Account, nil)

    current Sunny account

  • action (Symbol, String)

    CanCan action to authorize

  • resource (Class, ApplicationRecord)

    resource class or instance

Returns:

  • (Boolean)

    whether the employee may perform the action



17
18
19
20
21
22
# File 'app/services/assistant/employee_tool_authorization.rb', line 17

def allowed?(, action, resource)
  .present? &&
    !.disabled? &&
    .is_employee? &&
    CrmAbility.new(.party).can?(action, resource)
end