Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Fix bug, ensure that current_oauth_token method return not expirable …
Browse files Browse the repository at this point in the history
…token (#11147)

* Fix bug, ensure that current_oauth_token method return not expirable token

* Fix line too long on current_oauth_token method

* Fix issues generated by codeclimate revision

Co-authored-by: Pau Sentis <pau.sf@coditramuntana.com>
  • Loading branch information
PauSentis and pausentisCT authored Aug 8, 2021
1 parent a18e1b1 commit ee6ffaa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/lib/spree/core/controller_helpers/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ def set_token
end

def current_oauth_token
get_last_access_token = ->(user) { Doorkeeper::AccessToken.active_for(user).where(expires_in: nil).last }
create_access_token = ->(user) { Doorkeeper::AccessToken.create!(resource_owner_id: user.id) }
user = try_spree_current_user
return unless user

@current_oauth_token ||= Doorkeeper::AccessToken.active_for(user).last || Doorkeeper::AccessToken.create!(resource_owner_id: user.id)
@current_oauth_token ||= get_last_access_token.call(user) || create_access_token.call(user)
end

def store_location
Expand Down

0 comments on commit ee6ffaa

Please sign in to comment.