Commit cc0295b789a89a3f52e83e34b08ddf17b464308a
1 parent
6ea6ab7c
Exists in
master
and in
4 other branches
Only owner can remove project
Showing
6 changed files
with
13 additions
and
5 deletions
Show diff stats
app/controllers/application_controller.rb
... | ... | @@ -112,6 +112,10 @@ class ApplicationController < ActionController::Base |
112 | 112 | render file: Rails.root.join("public", "404"), layout: false, status: "404" |
113 | 113 | end |
114 | 114 | |
115 | + def render_403 | |
116 | + render file: Rails.root.join("public", "403"), layout: false, status: "403" | |
117 | + end | |
118 | + | |
115 | 119 | def require_non_empty_project |
116 | 120 | redirect_to @project if @project.empty_repo? |
117 | 121 | end | ... | ... |
app/controllers/projects_controller.rb
... | ... | @@ -89,6 +89,8 @@ class ProjectsController < ProjectResourceController |
89 | 89 | end |
90 | 90 | |
91 | 91 | def destroy |
92 | + return access_denied! unless can?(current_user, :remove_project, project) | |
93 | + | |
92 | 94 | # Disable the UsersProject update_repository call, otherwise it will be |
93 | 95 | # called once for every person removed from the project |
94 | 96 | UsersProject.skip_callback(:destroy, :after, :update_repository) | ... | ... |
app/views/help/permissions.html.haml
app/views/projects/_form.html.haml
... | ... | @@ -26,7 +26,7 @@ |
26 | 26 | |
27 | 27 | %span.cred Be careful. Changing project namespace can have unintended side effects |
28 | 28 | - else |
29 | - %a.btn.btn-small.disabled= @project.namespace.try(:human_name) || "/" | |
29 | + %a.btn.disabled= @project.namespace.try(:human_name) || "/" | |
30 | 30 | |
31 | 31 | %span.cred Only owner can change project namespace. |
32 | 32 | |
... | ... | @@ -69,5 +69,6 @@ |
69 | 69 | = f.submit 'Save', class: "btn save-btn" |
70 | 70 | = link_to 'Cancel', @project, class: "btn" |
71 | 71 | - unless @project.new_record? |
72 | - .right | |
73 | - = link_to 'Remove', @project, confirm: 'Are you sure?', method: :delete, class: "btn danger" | |
72 | + - if can?(current_user, :remove_project, @project) | |
73 | + .right | |
74 | + = link_to 'Remove', @project, confirm: 'Removed project can not be restored! Are you sure?', method: :delete, class: "btn danger" | ... | ... |
app/views/services/_gitlab_ci.html.haml