Commit acb5376b authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'fix-epic-link-create-perm' into 'master'

Check user permissions correctly

See merge request gitlab-org/gitlab!24946
parents 2dd90ff5 d533b4f8
...@@ -346,7 +346,7 @@ module EE ...@@ -346,7 +346,7 @@ module EE
elsif parent.has_ancestor?(self) elsif parent.has_ancestor?(self)
errors.add :parent, "This epic can't be added as it is already assigned to this epic's ancestor" errors.add :parent, "This epic can't be added as it is already assigned to this epic's ancestor"
elsif !preloaded_parent_group_and_descendants.include?(group) elsif !preloaded_parent_group_and_descendants.include?(group)
errors.add :parent, "This epic can't be added because parent and child epics must belong to the same group" errors.add :parent, "This epic can't be added because it must belong to the same group as the parent, or subgroup of the parent epic’s group"
elsif level_depth_exceeded?(parent) elsif level_depth_exceeded?(parent)
errors.add :parent, "This epic can't be added as the maximum depth of nested epics would be exceeded" errors.add :parent, "This epic can't be added as the maximum depth of nested epics would be exceeded"
end end
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
module EpicLinks module EpicLinks
class CreateService < IssuableLinks::CreateService class CreateService < IssuableLinks::CreateService
def execute def execute
unless can?(current_user, :admin_epic, issuable.group)
return error(issuables_not_found_message, 404)
end
if issuable.max_hierarchy_depth_achieved? if issuable.max_hierarchy_depth_achieved?
return error("This epic can't be added because the parent is already at the maximum depth from its most distant ancestor", 409) return error("This epic can't be added because the parent is already at the maximum depth from its most distant ancestor", 409)
end end
...@@ -54,8 +58,6 @@ module EpicLinks ...@@ -54,8 +58,6 @@ module EpicLinks
def linkable_issuables(epics) def linkable_issuables(epics)
@linkable_issuables ||= begin @linkable_issuables ||= begin
return [] unless can?(current_user, :admin_epic, issuable.group)
epics.select do |epic| epics.select do |epic|
linkable_epic?(epic) linkable_epic?(epic)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment