Welcome to mirror list, hosted at ThFree Co, Russian Federation.

token_info_controller.rb « oauth « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 626184150bd341feb6ee01a2e20021e77d804421 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

class Oauth::TokenInfoController < Doorkeeper::TokenInfoController
  include EnforcesTwoFactorAuthentication

  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::InvalidTokenResponse.new
      response.headers.merge!(error.headers)
      render json: error.body, status: error.status
    end
  end
end