Skip to content

Commit

Permalink
Merge pull request #15640 from opf/chore/make-delete-permission-required
Browse files Browse the repository at this point in the history
Make delete_permission required in the DeleteService
  • Loading branch information
oliverguenther authored May 22, 2024
2 parents a51984a + 6686b4f commit bb757ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/contracts/delete_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def authorized?
user.admin? && user.active?
when Proc
instance_exec(&permission)
when Symbol
model.project && user.allowed_in_project?(permission, model.project)
else
!model.project || user.allowed_in_project?(permission, model.project)
raise ArgumentError, "#{self.class} used without delete_permission. Set a Proc, or project-based permission symbol"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#++

module ProjectCustomFieldProjectMappings
class DeleteContract < BaseContract
class DeleteContract < ::DeleteContract
delete_permission :select_project_custom_fields
end
end

0 comments on commit bb757ed

Please sign in to comment.