Commit 3cce570c4c63efc1d0e2e264bdd1e4c2b4a2e530
1 parent
20ce3980
Exists in
master
and in
4 other branches
Allow forking of public projects by authenticated users. Fixes #4152
Showing
1 changed file
with
22 additions
and
1 deletions
Show diff stats
app/models/ability.rb
| ... | ... | @@ -38,10 +38,14 @@ class Ability |
| 38 | 38 | elsif team.reporters.include?(user) |
| 39 | 39 | rules << project_report_rules |
| 40 | 40 | |
| 41 | - elsif team.guests.include?(user) or project.public? | |
| 41 | + elsif team.guests.include?(user) | |
| 42 | 42 | rules << project_guest_rules |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | + if project.public? | |
| 46 | + rules << public_project_rules | |
| 47 | + end | |
| 48 | + | |
| 45 | 49 | if project.owner == user || user.admin? |
| 46 | 50 | rules << project_admin_rules |
| 47 | 51 | end |
| ... | ... | @@ -49,6 +53,23 @@ class Ability |
| 49 | 53 | rules.flatten |
| 50 | 54 | end |
| 51 | 55 | |
| 56 | + def public_project_rules | |
| 57 | + [ | |
| 58 | + :download_code, | |
| 59 | + :fork_project, | |
| 60 | + :read_project, | |
| 61 | + :read_wiki, | |
| 62 | + :read_issue, | |
| 63 | + :read_milestone, | |
| 64 | + :read_project_snippet, | |
| 65 | + :read_team_member, | |
| 66 | + :read_merge_request, | |
| 67 | + :read_note, | |
| 68 | + :write_issue, | |
| 69 | + :write_note | |
| 70 | + ] | |
| 71 | + end | |
| 72 | + | |
| 52 | 73 | def project_guest_rules |
| 53 | 74 | [ |
| 54 | 75 | :read_project, | ... | ... |