main
 1# frozen_string_literal: true
 2
 3module Oauth
 4  class MesController < ActionController::API
 5    include ActionController::HttpAuthentication::Token::ControllerMethods
 6    before_action :authenticate!
 7
 8    def show
 9      render json: @claims
10    end
11
12    private
13
14    def authenticate!
15      @claims = authenticate_with_http_token do |token, _options|
16        claims = Token.claims_for(token)
17        Token.revoked?(claims[:jti]) ? nil : claims
18      end
19      request_http_token_authentication if @claims.blank?
20    end
21  end
22end