Project

General

Profile

Defect #31168

Updated by Go MAEDA over 5 years ago

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. 

 <pre><code class="ruby"> ========================================================== 
 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 
 </code></pre> ==========================================================

Back