Defect #31168

[Redmine 4.0.2] Undefine method "alias_method_chain" Rails 5 upgrade

Added by Tu Nguyen Duy 12 months ago. Updated 12 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Resolution:Invalid Affected version:4.0.2

Description

Because Rails vesion 5.2 upgrade, method "alias_method_chain" don't work.
Would to expert help me to Replace method "alias_method_chain" in Redmine 4.0.2, rails 5.2.

require_dependency 'account_controller'

module AccountLockable
  module AccountControllerPatch
    # unloadable

    extend ActiveSupport::Concern

    included do
      # unloadable

      #alias_method_chain :invalid_credentials, :account_lock
    end

    def invalid_credentials_with_account_lock
      invalid_credentials_without_account_lock
      return if params[:username].blank?

      user = User.active.find_by_login(params[:username])
      return if user.blank?

      login_log = LoginLog.find_or_create_by(user_id: user.id)
      login_log.failed!(request.remote_ip)

      if login_log.lockable?
        user.lock!
        login_log.locked!

        AccountLockableMailer.account_locked(user, login_log).deliver
      end
    end

  end
end

AccountLockable::AccountControllerPatch.tap do |mod|
  AccountController.send :include, mod unless AccountController.include?(mod)
end

History

#1 Updated by Go MAEDA 12 months ago

  • Description updated (diff)
  • Category deleted (Accounts / authentication)
  • Status changed from New to Closed
  • Resolution set to Invalid

Please use forums for questions. Reading How to request help may be helpful for you.

Also available in: Atom PDF