Skip to content

Commit

Permalink
Set rebuild? policy for Token::WorkflowPolicy
Browse files Browse the repository at this point in the history
To check if the token's user can rebuild the object to authorize
(package or project).
  • Loading branch information
saraycp authored and vpereira committed Sep 22, 2021
1 parent 4ac19c3 commit eab7b00
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/api/app/policies/token/workflow_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ class Token::WorkflowPolicy < TokenPolicy
def trigger?
user.is_active? && Flipper.enabled?(:trigger_workflow, user)
end

def rebuild?
return PackagePolicy.new(user, record.object_to_authorize).update? if record.object_to_authorize.is_a?(Package)
return ProjectPolicy.new(user, record.object_to_authorize).update? if record.object_to_authorize.is_a?(Project)
end
end

0 comments on commit eab7b00

Please sign in to comment.