module Touth::ActionControllerSupport::ClassMethods
Public Instance Methods
token_authentication_for(resource_name)
click to toggle source
# File lib/touth/action_controller_support.rb, line 5 def token_authentication_for(resource_name) unless @_init_token_authenticator_hook prepend_before_action :set_token_authorized_resource! @_init_token_authenticator_hook = true end resource_name = Touth.get_resource_name resource_name callback_name = "authenticate_#{resource_name}!".to_sym unless method_defined? callback_name define_method "#{resource_name}_signed_in?" do !!Touth::Authenticator.current(resource_name) end define_method "current_#{resource_name}" do Touth::Authenticator.current resource_name end define_method callback_name do authenticate_token_for! resource_name end protected callback_name before_action callback_name end end