debian-mirror-gitlab/app/controllers/oauth/token_info_controller.rb

22 lines
642 B
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
class Oauth::TokenInfoController < Doorkeeper::TokenInfoController
2020-08-18 19:51:02 +05:30
include EnforcesTwoFactorAuthentication
2020-03-13 15:44:24 +05:30
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
2022-03-02 08:16:31 +05:30
error = Doorkeeper::OAuth::InvalidTokenResponse.new
2020-03-13 15:44:24 +05:30
response.headers.merge!(error.headers)
render json: error.body, status: error.status
end
end
end