2020-02-17 22:08:54 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Oauth::TokenInfoController < Doorkeeper::TokenInfoController
|
2020-08-05 17:09:40 -04:00
|
|
|
include EnforcesTwoFactorAuthentication
|
|
|
|
|
2020-02-17 22:08:54 -05:00
|
|
|
def show
|
|
|
|
if doorkeeper_token && doorkeeper_token.accessible?
|
|
|
|
token_json = doorkeeper_token.as_json
|
|
|
|
|
|
|
|
# maintain backwards compatibility
|
|
|
|
render json: token_json.merge(
|
|
|
|
'scopes' => token_json[:scope],
|
|
|
|
'expires_in_seconds' => token_json[:expires_in]
|
|
|
|
), status: :ok
|
|
|
|
else
|
|
|
|
error = Doorkeeper::OAuth::ErrorResponse.new(name: :invalid_request)
|
|
|
|
response.headers.merge!(error.headers)
|
|
|
|
render json: error.body, status: error.status
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|