I want to override a method from Redmine Core using a Patch in a plugin but I'm not able to make it working :-(.
I want to change the behavior of the method try_to_login from the Redmine core.
Here is my Init.rb:
require 'redmine'
require 'user_patch'
ActionDispatch::Callbacks.to_prepare do
require_dependency 'project'
require_dependency 'principal'
require_dependency 'user'
unless User.included_modules.include? UserPatch
User.send :include, UserPatch
end
end
Redmine::Plugin.register :security do
name 'Security plugin'
author 'Author name'
description 'This is a plugin for Redmine'
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
end
and my patch file:
module UserPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
alias_method :try_to_login, :try_to_login_with_patch
end
end
module InstanceMethods
# Returns the user that matches provided login and password, or nil
def try_to_login_with_patch(login, password, active_only=true)
<do somthing ...>
end
end
end
Any idea what is wrong in this ?
Thanks you in avance.
Regards,
Aniss