fix: Macros authorizations (#5779)

Macros policy update.

ref: #5730
This commit is contained in:
Tejaswini Chile
2022-11-08 07:16:00 +05:30
committed by GitHub
parent 479d88a480
commit 48373628a1
8 changed files with 177 additions and 38 deletions

View File

@@ -8,22 +8,34 @@ class MacroPolicy < ApplicationPolicy
end
def show?
true
@record.global? || author?
end
def update?
true
author? || (@account_user.administrator? && @record.global?)
end
def destroy?
true
author? || orphan_record?
end
def execute?
true
@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