Skip to content
Snippets Groups Projects
Commit 9ea5766c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Improve permissions on tags/branches

parent 29306dd6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -91,6 +91,10 @@ class ApplicationController < ActionController::Base
return access_denied! unless can?(current_user, :download_code, project) or project.public?
end
 
def authorize_push!
return access_denied! unless can?(current_user, :push_code, project)
end
def authorize_create_team!
return access_denied! unless can?(current_user, :create_team, nil)
end
Loading
Loading
Loading
Loading
@@ -3,7 +3,9 @@ class Projects::BranchesController < Projects::ApplicationController
before_filter :authorize_read_project!
before_filter :require_non_empty_project
 
before_filter :authorize_admin_project!, only: [:destroy, :create]
before_filter :authorize_code_access!
before_filter :authorize_push!, only: [:create]
before_filter :authorize_admin_project!, only: [:destroy]
 
def index
@branches = Kaminari.paginate_array(@repository.branches).page(params[:page]).per(30)
Loading
Loading
class Projects::TagsController < Projects::ApplicationController
# Authorize
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
 
before_filter :authorize_admin_project!, only: [:destroy, :create]
before_filter :authorize_code_access!
before_filter :authorize_push!, only: [:create]
before_filter :authorize_admin_project!, only: [:destroy]
 
def index
@tags = Kaminari.paginate_array(@project.repository.tags).page(params[:page]).per(30)
Loading
Loading
Loading
Loading
@@ -10,6 +10,7 @@
 
 
%hr
- if can? current_user, :push_code, @project
= link_to new_project_branch_path(@project), class: 'btn btn-create' do
%i.icon-add-sign
New branch
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment