Skip to content

Commit 3645cae

Browse files
committed
Fix for heartbeat endpoint - JP
1 parent 10380fa commit 3645cae

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

app/controllers/api/v2/base_api_controller.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,15 @@ def me
3636
# define instance variable json and associated getter and setter methods
3737
attr_accessor :json
3838

39-
def get_client_and_server_details # rubocop:todo Naming/AccessorMethodName
40-
@server = ApplicationService.application_name
41-
@client = OauthApplication.find(doorkeeper_token.application_id) if doorkeeper_token
42-
@scopes = doorkeeper_token.scopes.to_a if doorkeeper_token
43-
return unless doorkeeper_token&.resource_owner_id
44-
45-
@resource_owner = User.find(doorkeeper_token.resource_owner_id)
39+
def get_client_and_server_details
40+
@application = ApplicationService.application_name
41+
@caller = request.remote_ip if @client.blank?
42+
@caller = @client.is_a?(User) ? @client.name(false) : @client.name if @client.present?
4643
end
4744

4845
def log_access
49-
Rails.logger.info "Client (OAuth) application name: #{@client.name}"
50-
Rails.logger.info "Client (OAuth) application uid: #{@client.uid}"
46+
Rails.logger.info "Client (OAuth) application name: #{@client.name}" if @client.present?
47+
Rails.logger.info "Client (OAuth) application uid: #{@client.uid}" if @client.present?
5148
Rails.logger.info "Resource owner id: #{@resource_owner.id}" if @resource_owner
5249
end
5350

app/views/api/v2/_standard_response.json.jbuilder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ json.ignore_nil!
1515
json.server @server
1616
json.source "#{request.method} #{request.path}"
1717
json.time Time.now.to_formatted_s(:iso8601)
18-
json.client @client.name
18+
json.client @client.name if @client.present?
1919
json.code response.status
2020
json.message Rack::Utils::HTTP_STATUS_CODES[response.status]
2121

0 commit comments

Comments
 (0)