Skip to content

Commit e6026eb

Browse files
committed
Show assignment option only if user is acutally authorized to do so
Right now we show the assignment option to every user. We should only show it if the user is actually authorized to assign someone.
1 parent 13a6c8b commit e6026eb

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/api/app/policies/package_policy.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,20 @@ def source_access?
5858

5959
record.enabled_for?('sourceaccess', nil, nil)
6060
end
61+
62+
def assign?
63+
return false unless Flipper.enabled?(:foster_collaboration, user)
64+
return true if user.admin?
65+
66+
assigneer_is_a_collaborator?
67+
end
68+
69+
private
70+
71+
def assigneer_is_a_collaborator?
72+
collaborators = (record.relationships + record.project.relationships).map(&:user)
73+
return false if collaborators.empty?
74+
75+
collaborators.include?(user)
76+
end
6177
end

src/api/app/views/webui/package/side_links/_assignments.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
%p.mb-0.link-danger
99
%i.fas.fa-user-minus
1010
Unassign
11-
- else
11+
- elsif policy(package).assign?
1212
.dropdown#assignment-search
1313
%button.btn.btn-sm.dropdown-toggle.ps-0.border-0{ data: { 'bs-toggle': 'dropdown', 'bs-auto-close': 'outside' }, aria: { expanded: 'false' } }
1414
%strong

0 commit comments

Comments
 (0)