Fix connected device model for request without device id [SCI-7972]

This commit is contained in:
Andrej 2023-02-28 16:42:56 +01:00
parent e58fb71adf
commit 64da4c5368

View file

@ -2,6 +2,7 @@
class ConnectedDevice < ApplicationRecord
belongs_to :oauth_access_token, class_name: 'Doorkeeper::AccessToken'
validates :uid, presence: true
after_destroy :revoke_token
@ -10,8 +11,10 @@ class ConnectedDevice < ApplicationRecord
end
def self.from_request_headers(headers, token = nil)
return unless headers['Device-Id']
current_token = Doorkeeper::AccessToken.find_by(
token: headers['Authorization'].gsub(/Bearer\s/, '')
token: headers['Authorization']&.gsub(/Bearer\s/, '')
)
return unless token || current_token