mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-26 09:43:29 +08:00
Change the way ConnectedDevice logging is added to TokensController [SCI-8287] (#5634)
This commit is contained in:
parent
62411fb77b
commit
4fe0ad026d
2 changed files with 21 additions and 12 deletions
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Doorkeeper
|
||||
module ConnectedDeviceLogging
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
after_action :log_connected_device, only: :create
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def log_connected_device
|
||||
return if @authorize_response.is_a?(Doorkeeper::OAuth::ErrorResponse)
|
||||
|
||||
ConnectedDevice.from_request_headers(request.headers, @authorize_response&.token)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -72,18 +72,8 @@ module Scinote
|
|||
# Only Authorization endpoint
|
||||
Doorkeeper::AuthorizationsController.layout 'sign_in_halt'
|
||||
|
||||
# Add Connected Device logging
|
||||
Doorkeeper::TokensController.class_eval do
|
||||
after_action :log_connected_device, only: :create
|
||||
|
||||
private
|
||||
|
||||
def log_connected_device
|
||||
return if @authorize_response.is_a?(Doorkeeper::OAuth::ErrorResponse)
|
||||
|
||||
ConnectedDevice.from_request_headers(request.headers, @authorize_response&.token)
|
||||
end
|
||||
end
|
||||
# Add connected device logging when creating tokens
|
||||
Doorkeeper::TokensController.include(Doorkeeper::ConnectedDeviceLogging)
|
||||
end
|
||||
|
||||
config.action_view.field_error_proc = Proc.new { |html_tag, instance|
|
||||
|
|
Loading…
Reference in a new issue