Sha256: e3ba3ecb42a45ae221d37f5c7a6ba868baff63e780e0b24931ee7d12f31bb5f3
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
module GoogleAuthenticatorRails module ActionController class RailsAdapter class LoadedTooLateError < StandardError def initialize super("GoogleAuthenticatorRails is trying to prepend a before_filter in ActionController::Base. Because you've already defined" + " ApplicationController, your controllers will not get this before_filter. Please load GoogleAuthenticatorRails before defining" + " ApplicationController.") end end def initialize(controller) @controller = controller end def cookies @controller.send(:cookies) end end module Integration def self.included(klass) if klass.descendants.map(&:name).include?("ApplicationController") raise RailsAdapter::LoadedTooLateError.new end method = klass.respond_to?(:prepend_before_action) ? :prepend_before_action : :prepend_before_filter klass.send(method, :activate_google_authenticator_rails) end private def activate_google_authenticator_rails GoogleAuthenticatorRails::Session::Base.controller = RailsAdapter.new(self) end end end end ActiveSupport.on_load(:action_controller) do ActionController::Base.send(:include, GoogleAuthenticatorRails::ActionController::Integration) end
Version data entries
3 entries across 3 versions & 1 rubygems