I'm not sure if this issue is a general Rails issue or Redmine specific.
There is a User class that has a try_to_login class method. I wrote a module containing the method_alias_chain method to wrap this method and provide additional functionality. This works fine if I log into the console and call try_to_login. My wrapper will be done and everything will be fine. However, when I run this on the server, only the vanilla method is called. The wrapper never starts. I added the logger command to the vanilla method to make sure it is being called.
Here is a simplified version of the code:
require_dependency 'principal'
require_dependency 'user'
require 'login_attempt_count'
module UserLoginAttemptLimiterPatch
def self.included(base)
base.extend ClassMethods
base.class_eval do
class << self
alias_method_chain :try_to_login, :attempt_limit
end
end
end
module ClassMethods
def try_to_login_with_attempt_limit(login, password)
user = try_to_login_without_attempt_limit login, password
user
end
def authentication_failed(login)
end
end
end
User.send(:include, UserLoginAttemptLimiterPatch)
In addition, this module is required when loading the plugin.