Commit f4cb71d3 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'feature-jp-issue-permission' into 'master'

API issues - minor cleanup of permission check

See merge request gitlab-org/gitlab-ce!29423
parents 2a29f910 a17a1556
...@@ -164,6 +164,7 @@ class ProjectPolicy < BasePolicy ...@@ -164,6 +164,7 @@ class ProjectPolicy < BasePolicy
enable :set_issue_iid enable :set_issue_iid
enable :set_issue_created_at enable :set_issue_created_at
enable :set_issue_updated_at
enable :set_note_created_at enable :set_note_created_at
end end
......
...@@ -252,14 +252,9 @@ module API ...@@ -252,14 +252,9 @@ module API
issue = user_project.issues.find_by!(iid: params.delete(:issue_iid)) issue = user_project.issues.find_by!(iid: params.delete(:issue_iid))
authorize! :update_issue, issue authorize! :update_issue, issue
# Setting updated_at only allowed for admins and owners as well # Setting updated_at is allowed only for admins and owners
if params[:updated_at].present? params.delete(:updated_at) unless current_user.can?(:set_issue_updated_at, user_project)
if current_user.admin? || user_project.owner == current_user || current_user.owned_groups.include?(user_project.owner)
issue.system_note_timestamp = params[:updated_at] issue.system_note_timestamp = params[:updated_at]
else
params.delete(:updated_at)
end
end
update_params = declared_params(include_missing: false).merge(request: request, api: true) update_params = declared_params(include_missing: false).merge(request: request, api: true)
......
...@@ -66,7 +66,7 @@ describe ProjectPolicy do ...@@ -66,7 +66,7 @@ describe ProjectPolicy do
%i[ %i[
change_namespace change_visibility_level rename_project remove_project change_namespace change_visibility_level rename_project remove_project
archive_project remove_fork_project destroy_merge_request destroy_issue archive_project remove_fork_project destroy_merge_request destroy_issue
set_issue_iid set_issue_created_at set_note_created_at set_issue_iid set_issue_created_at set_issue_updated_at set_note_created_at
] ]
end end
......
...@@ -64,7 +64,7 @@ RSpec.shared_context 'ProjectPolicy context' do ...@@ -64,7 +64,7 @@ RSpec.shared_context 'ProjectPolicy context' do
%i[ %i[
change_namespace change_visibility_level rename_project remove_project change_namespace change_visibility_level rename_project remove_project
archive_project remove_fork_project destroy_merge_request destroy_issue archive_project remove_fork_project destroy_merge_request destroy_issue
set_issue_iid set_issue_created_at set_note_created_at set_issue_iid set_issue_created_at set_issue_updated_at set_note_created_at
] ]
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