From 14467d218152e9d7f1b0db18d9f2fb57c0f262f0 Mon Sep 17 00:00:00 2001 From: Jared Beck Date: Wed, 11 Sep 2019 13:36:30 -0400 Subject: [PATCH] Delete AuthlogicLoadedTooLateError This error no longer seems to be necessary. I tested this in a new rails 6.0.0 application. In the following, my debug output is prefixed with "->". ``` bin/rails server -> loading rails_adapter.rb => Booting Puma ... * Listening on tcp://localhost:3000 ... -> RailsImplementation included into ActionController::Base -> RailsImplementation included into ActionController::API -> loading application_controller.rb Started GET "/" for 127.0.0.1 at 2019-09-11 13:33:05 -0400 Processing by HomeController#index as HTML -> activate_authlogic Rendering home/index.html.erb within layouts/application ``` We can see that the `activate_authlogic` callback still occurs. So, raising an AuthlogicLoadedTooLateError would be incorrect. And, of course, I tested a normal sign in POST. --- .../controller_adapters/rails_adapter.rb | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/lib/authlogic/controller_adapters/rails_adapter.rb b/lib/authlogic/controller_adapters/rails_adapter.rb index 3fb9f317..4b29ff78 100644 --- a/lib/authlogic/controller_adapters/rails_adapter.rb +++ b/lib/authlogic/controller_adapters/rails_adapter.rb @@ -7,20 +7,6 @@ module ControllerAdapters # Similar to how ActiveRecord has an adapter for MySQL, PostgreSQL, SQLite, # etc. class RailsAdapter < AbstractAdapter - # :nodoc: - class AuthlogicLoadedTooLateError < StandardError - def message - <<~EOS.squish - Authlogic is trying to add a callback to ActionController::Base but - ApplicationController has already been loaded, so the callback won't - be copied into your application. Generally this is due to another - gem or plugin requiring your ApplicationController prematurely, such - as the resource_controller plugin. Please require Authlogic first, - before these other gems / plugins. - EOS - end - end - def authenticate_with_http_basic(&block) controller.authenticate_with_http_basic(&block) end @@ -43,16 +29,7 @@ def request_content_type # "activates" authlogic. module RailsImplementation def self.included(klass) # :nodoc: - if defined?(::ApplicationController) - raise AuthlogicLoadedTooLateError - end - - # In Rails 4.0.2, the *_filter methods were renamed to *_action. - if klass.respond_to? :prepend_before_action - klass.prepend_before_action :activate_authlogic - else - klass.prepend_before_filter :activate_authlogic - end + klass.prepend_before_action :activate_authlogic end private