module TokenAuthenticateMe::Concerns::Controllers::Authenticateable

Public Instance Methods

token_handler(token, options) click to toggle source

Standard authentication routine, override to implement different auth strategies.

# File lib/token_authenticate_me/concerns/controllers/authenticateable.rb, line 15
def token_handler(token, options)
  authentication = TokenAuthenticateMe::Authentication.new(token: token)
  authentication.authenticate(options)
end

Protected Instance Methods

authenticate() click to toggle source

`authenticated_session` and `render_unauthorized` are specific to controllers. Ex: Could render json or http status code for unauthorized, or could redirect to a different url for server rendered pages. Could authenticate using headers or params, or cookie sessions depending on controller type.

# File lib/token_authenticate_me/concerns/controllers/authenticateable.rb, line 26
def authenticate
  authenticated_session || render_unauthorized
end
current_user() click to toggle source
# File lib/token_authenticate_me/concerns/controllers/authenticateable.rb, line 30
def current_user
  return unless authenticated_session
  authenticated_session.user
end