module GrapeTokenAuth::TokenValidationAPICore

Contains the major functionality of TokenValidation

Public Class Methods

included(base) click to toggle source
# File lib/grape_token_auth/apis/token_validation_api.rb, line 5
def self.included(base)
  base.get '/validate_token' do
    token_authorizer = TokenAuthorizer.new(AuthorizerData.from_env(env))
    resource = token_authorizer.find_resource(base.resource_scope)
    if resource
      status 200
      present data: resource.token_validation_response
    else
      throw(:warden, 'errors' => 'Invalid login credentials')
    end
  end
end