I've created a plugin on redmine which modifies the core of RepositoryControler.
I've added a patch with new function inside this controller and I can call this function based on role permissions.
But to set up correctly the permissions I need to configure before_filter
with authorization (:authorize
) for my new function.
The trouble is because adding the before_filter inside my patch doesn't work and I don't know what is the best manner to do it. Following my code:
client.rb
module RepositoriesPatch
require_dependency 'repositories_controller'
def self.included(base)
base.send(:include, InstanceMethods)
end
end
module InstanceMethods
require_dependency 'repositories_controller'
#I THINK THE BEFORE_FILTER SHOULD BE PLACED HERE, BUT IT DIDN'T WORKED.
# before_filter :authorize, :only => :exec_client (????????)
def exec_client
begin
....
end
end
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
init.rb
permission :repositories, :repositories => :exec_client
project_module :repository do
permission :exec, :repository => :exec_client
end
Rails.configuration.to_prepare do
RepositoriesController.send(:include, RepositoriesPatch)
end
settings :default => {'empty' => true}, :partial => 'settings/gerar_versao_configuration'
end
before_filter
must be evaluated inside the class as follows:
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
before_filter :authorize, :only => :exec_client
end
end