diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-07-25 22:40:44 -0600 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-07-25 22:40:44 -0600 |
commit | ed6c8238f3524feeab187b607362806ed1c666ad (patch) | |
tree | 670a3a811e2a65e97d86839c14bb62098730d8a6 /app | |
parent | bbab5d014f10914b1e5d7a73dc0e85ea57344979 (diff) | |
download | gitlab-ce-ed6c8238f3524feeab187b607362806ed1c666ad.tar.gz |
Add access checks for diff note and discussion resolution
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ability.rb | 8 | ||||
-rw-r--r-- | app/models/discussion.rb | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index f33c8d61d3f..ac3bf441c32 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -257,6 +257,7 @@ class Ability :create_merge_request, :create_wiki, :push_code, + :resolve_note, :create_container_image, :update_container_image, :create_environment, @@ -426,7 +427,8 @@ class Ability rules += [ :read_note, :update_note, - :admin_note + :admin_note, + :resolve_note ] end @@ -434,6 +436,10 @@ class Ability rules += project_abilities(user, note.project) end + if note.for_merge_request? && note.noteable.author == user + rules << :resolve_note + end + rules end diff --git a/app/models/discussion.rb b/app/models/discussion.rb index 64116d225ae..cc586933112 100644 --- a/app/models/discussion.rb +++ b/app/models/discussion.rb @@ -63,6 +63,14 @@ class Discussion notes.any?(&:to_be_resolved?) end + def can_resolve?(current_user) + return false unless current_user + return false unless resolvable? + + current_user == self.noteable.author || + can?(current_user, :push_code, self.project) + end + def resolve!(current_user) notes.each do |note| note.resolve!(current_user) if note.resolvable? |