Chatwoot/app/policies/macro_policy.rb
Tejaswini Chile 48373628a1
fix: Macros authorizations (#5779)
Macros policy update.

ref: #5730
2022-11-07 17:46:00 -08:00

41 lines
578 B
Ruby

class MacroPolicy < ApplicationPolicy
def index?
true
end
def create?
true
end
def show?
@record.global? || author?
end
def update?
author? || (@account_user.administrator? && @record.global?)
end
def destroy?
author? || orphan_record?
end
def execute?
@record.global? || author?
end
def attach_file?
true
end
private
def author?
@record.created_by == @account_user.user
end
def orphan_record?
return @account_user.administrator? if @record.created_by.nil? && @record.global?
false
end
end