gonzalo-bulnes/simple_token_authentication

View on GitHub
lib/simple_token_authentication/devise_fallback_handler.rb

Summary

Maintainability
A
0 mins
Test Coverage
module SimpleTokenAuthentication
  class DeviseFallbackHandler
    include Singleton

    # Fallback to the Devise authentication strategies.
    def fallback!(controller, entity)
      authenticate_entity!(controller, entity)
    end

    # Devise authentication is performed through a controller
    # which includes Devise::Controllers::Helpers
    # See http://rdoc.info/github/plataformatec/devise/master/\
    #            Devise/Controllers/Helpers#define_helpers-class_method
    def authenticate_entity!(controller, entity)
      controller.send("authenticate_#{entity.name_underscore}!".to_sym)
    end
  end
end