lib/devise_instant2fa/controllers/helpers.rb in devise_instant2fa-1.0.0 vs lib/devise_instant2fa/controllers/helpers.rb in devise_instant2fa-1.0.1

- old
+ new

@@ -1,11 +1,15 @@ module DeviseInstant2fa module Controllers module Helpers extend ActiveSupport::Concern - included do - before_action :handle_two_factor_authentication, :if => :is_signing_in? + def self.included(source) + if source.respond_to?(:before_action) # Rails 4+ + source.send(:before_action, :handle_two_factor_authentication, :if => :is_signing_in?) + elsif source.respond_to?(:before_filter) # Rails 3 + source.send(:before_filter, :handle_two_factor_authentication, :if => :is_signing_in?) + end end def is_devise_sessions_controller? self.class == Devise::SessionsController || self.class.ancestors.include?(Devise::SessionsController) end