allow for global permission check in non project context

pull/5233/head
Jens Ulferts 8 years ago committed by Markus Kahl
parent 635c6cdec6
commit ebb519b9dc
  1. 4
      lib/api/v3/queries/create_form_representer.rb
  2. 4
      lib/api/v3/queries/update_form_representer.rb

@ -58,8 +58,8 @@ module API
def allow_commit?
represented.name.present? && (
(!represented.is_public && current_user.allowed_to?(:save_queries, represented.project)) ||
(represented.is_public && current_user.allowed_to?(:manage_public_queries, represented.project))
(!represented.is_public && current_user.allowed_to?(:save_queries, represented.project, global: represented.project.nil?)) ||
(represented.is_public && current_user.allowed_to?(:manage_public_queries, represented.project, global: represented.project.nil?))
) && @errors.empty?
end
end

@ -58,8 +58,8 @@ module API
def allow_commit?
represented.name.present? && (
(!represented.is_public && current_user.allowed_to?(:save_queries, represented.project)) ||
(represented.is_public && current_user.allowed_to?(:manage_public_queries, represented.project))
(!represented.is_public && current_user.allowed_to?(:save_queries, represented.project, global: represented.project.nil?)) ||
(represented.is_public && current_user.allowed_to?(:manage_public_queries, represented.project, global: represented.project.nil?))
) && @errors.empty?
end
end

Loading…
Cancel
Save