diff options
author | Rémy Coutable <remy@rymai.me> | 2016-07-05 18:55:35 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-07-05 18:55:35 +0200 |
commit | 19b80e82521384284227b31003889c9ac41b7c8c (patch) | |
tree | 8d6a893486aa326fcff8d17dff4edf1481f2c554 /app/models/ability.rb | |
parent | 9ea80a196f14f55599ab9c9831788dd970a36966 (diff) | |
download | gitlab-ce-19b80e82521384284227b31003889c9ac41b7c8c.tar.gz |
Add a migration to remove requesters that are owners of their project18790-dont-show-request-button-to-project-owner
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'app/models/ability.rb')
-rw-r--r-- | app/models/ability.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 2c0fd0338fd..eeb0ceba081 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -171,14 +171,9 @@ class Ability # Allow to read builds for internal projects rules << :read_build if project.public_builds? - group_member = - project.group && - ( - project.group.members.exists?(user_id: user.id) || - project.group.requesters.exists?(user_id: user.id) - ) - - rules << :request_access unless owner || group_member || project.team.member?(user) + unless owner || project.team.member?(user) || project_group_member?(project, user) + rules << :request_access + end end if project.archived? @@ -501,8 +496,7 @@ class Ability target_user = subject.user project = subject.project - # Allow owners that requested access to their own project to destroy themselves - if target_user != project.owner || subject.request? + unless target_user == project.owner can_manage = project_abilities(user, project).include?(:admin_project_member) if can_manage @@ -582,5 +576,13 @@ class Ability rules end + + def project_group_member?(project, user) + project.group && + ( + project.group.members.exists?(user_id: user.id) || + project.group.requesters.exists?(user_id: user.id) + ) + end end end |