class TokenAuthenticateMe::Authentication

Attributes

token[R]
token_handler[R]

Public Class Methods

default_token_handler(token, _options) click to toggle source
# File lib/token_authenticate_me/authentication.rb, line 3
def self.default_token_handler(token, _options)
  session = TokenAuthenticateMe::Session.find_by_key(token)

  if session && session.expiration > DateTime.now
    session
  else
    false
  end
end
new(token:, token_handler: TokenAuthenticateMe::Authentication.method(:default_token_handler)) click to toggle source
# File lib/token_authenticate_me/authentication.rb, line 15
def initialize(token:, token_handler: TokenAuthenticateMe::Authentication.method(:default_token_handler))
  @token = token
  @token_handler = token_handler
end

Public Instance Methods

authenticate(options = {}) click to toggle source
# File lib/token_authenticate_me/authentication.rb, line 20
def authenticate(options = {})
  token_handler.call(token, options)
end