diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-03-16 20:16:42 -0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-03-16 20:16:42 -0300 |
commit | 44c127447b5a3cfc7aaea6f19e18baf9f42ad500 (patch) | |
tree | f386dbb06fec8c5fdec92812394ac63cf67183a0 /app/models/ability.rb | |
parent | ec20fdf366843e60ed30abb5322c3c1b8f471b4a (diff) | |
parent | 59064aeeef8562a87d4d03efa9b11012a007e261 (diff) | |
download | gitlab-ce-44c127447b5a3cfc7aaea6f19e18baf9f42ad500.tar.gz |
Merge 4009-external-users into issue_12658
Diffstat (limited to 'app/models/ability.rb')
-rw-r--r-- | app/models/ability.rb | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index bd001ef1545..455ea7bcc69 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -109,23 +109,10 @@ class Ability key = "/user/#{user.id}/project/#{project.id}" RequestStore.store[key] ||= begin - team = project.team + # Push abilities on the users team role + rules.push(*project_team_rules(project.team, user)) - # Rules based on role in project - if team.master?(user) - rules.push(*project_master_rules) - - elsif team.developer?(user) - rules.push(*project_dev_rules) - - elsif team.reporter?(user) - rules.push(*project_report_rules) - - elsif team.guest?(user) - rules.push(*project_guest_rules) - end - - if project.public? || project.internal? + if project.public? || (project.internal? && !user.external?) rules.push(*public_project_rules) # Allow to read builds for internal projects @@ -148,6 +135,19 @@ class Ability end end + def project_team_rules(team, user) + # Rules based on role in project + if team.master?(user) + project_master_rules + elsif team.developer?(user) + project_dev_rules + elsif team.reporter?(user) + project_report_rules + elsif team.guest?(user) + project_guest_rules + end + end + def public_project_rules @public_project_rules ||= project_guest_rules + [ :download_code, @@ -360,7 +360,7 @@ class Ability ] end - if snippet.public? || snippet.internal? + if snippet.public? || (snippet.internal? && !user.external?) rules << :read_personal_snippet end |