From a83d64eaab02b0515e2d43739f116b321d5f6adf Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 6 Feb 2012 19:04:56 +0400 Subject: [PATCH] [refs #150] Fix collaborators cancan authorize --- app/controllers/collaborators_controller.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/controllers/collaborators_controller.rb b/app/controllers/collaborators_controller.rb index f05ab25ac..44ab07f98 100644 --- a/app/controllers/collaborators_controller.rb +++ b/app/controllers/collaborators_controller.rb @@ -6,9 +6,10 @@ class CollaboratorsController < ApplicationController before_filter :find_users before_filter :find_groups - load_and_authorize_resource :project + load_resource :project + before_filter :authorize_collaborators - def index + def index redirect_to edit_project_collaborators_path(@project) end @@ -49,7 +50,7 @@ class CollaboratorsController < ApplicationController groups_for_removing.each do |u| Relation.by_object(u).by_target(@project).each {|r| r.destroy} end - + # Create relations Relation::ROLES.each { |r| #users_for_creating = users_for_creating params[:user].keys.map{|p| p.to_i} - @project.collaborators.map(&:id) @@ -130,4 +131,8 @@ class CollaboratorsController < ApplicationController def find_groups @groups = @project.groups#Group.all end + + def authorize_collaborators + authorize! :update, @project + end end