mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 02:04:33 +08:00
Fix connected device model for request without device id [SCI-7972]
This commit is contained in:
parent
e58fb71adf
commit
64da4c5368
1 changed files with 4 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class ConnectedDevice < ApplicationRecord
|
class ConnectedDevice < ApplicationRecord
|
||||||
belongs_to :oauth_access_token, class_name: 'Doorkeeper::AccessToken'
|
belongs_to :oauth_access_token, class_name: 'Doorkeeper::AccessToken'
|
||||||
|
validates :uid, presence: true
|
||||||
|
|
||||||
after_destroy :revoke_token
|
after_destroy :revoke_token
|
||||||
|
|
||||||
|
@ -10,8 +11,10 @@ class ConnectedDevice < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_request_headers(headers, token = nil)
|
def self.from_request_headers(headers, token = nil)
|
||||||
|
return unless headers['Device-Id']
|
||||||
|
|
||||||
current_token = Doorkeeper::AccessToken.find_by(
|
current_token = Doorkeeper::AccessToken.find_by(
|
||||||
token: headers['Authorization'].gsub(/Bearer\s/, '')
|
token: headers['Authorization']&.gsub(/Bearer\s/, '')
|
||||||
)
|
)
|
||||||
|
|
||||||
return unless token || current_token
|
return unless token || current_token
|
||||||
|
|
Loading…
Reference in a new issue