Sha256: 6175ada2784d3334140b6515af27ec68a7ab8ccda48256f34e707db11a1c547c
Contents?: true
Size: 1.5 KB
Versions: 6
Compression:
Stored size: 1.5 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 if defined?(ActionController::Base) ActionController::Base.send(:include, GoogleAuthenticatorRails::ActionController::Integration) end if defined?(ActionController::API) ActionController::API.send(:include, GoogleAuthenticatorRails::ActionController::Integration) end end
Version data entries
6 entries across 6 versions & 1 rubygems