summaryrefslogtreecommitdiff
path: root/lib/api/helpers
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-08-22 13:10:54 +0100
committerSean McGivern <sean@gitlab.com>2018-08-22 14:17:29 +0100
commitaff7dccc1f13e86b44dfa1530c6b5068dbb18f00 (patch)
tree0193754c17b7023499ad4d1cd438cb287547793d /lib/api/helpers
parentb63ed7cff664bc1ee0bf70912fffd4814f757079 (diff)
downloadgitlab-ce-aff7dccc1f13e86b44dfa1530c6b5068dbb18f00.tar.gz
Use policies to determine if attributes can be set in the API
This is more idiomatic than checking membership explicitly.
Diffstat (limited to 'lib/api/helpers')
-rw-r--r--lib/api/helpers/notes_helpers.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/api/helpers/notes_helpers.rb b/lib/api/helpers/notes_helpers.rb
index 7885e3fa1e1..7b1f5c2584b 100644
--- a/lib/api/helpers/notes_helpers.rb
+++ b/lib/api/helpers/notes_helpers.rb
@@ -92,10 +92,7 @@ module API
parent = noteable_parent(noteable)
- if opts[:created_at]
- opts.delete(:created_at) unless
- (current_user.admin? || user_project.owner == current_user || current_user.owned_groups.include?(user_project.owner))
- end
+ opts.delete(:created_at) unless current_user.can?(:set_note_created_at, policy_object)
opts[:updated_at] = opts[:created_at] if opts[:created_at]