Fix current_resource_owner caching implementation

This commit is contained in:
Fosco Marotto 2021-01-30 01:27:11 -05:00
parent c84e7e3451
commit 0587875a75
1 changed files with 5 additions and 4 deletions

View File

@ -63,11 +63,12 @@ class Api::BaseController < ApplicationController
end
def current_resource_owner
return nil if cookies.signed['_session_id'].nil?
# return @current_user if doorkeeper_token.nil?
@current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do
User.find(doorkeeper_token.resource_owner_id)
if doorkeeper_token
@current_user ||= Rails.cache.fetch("dk:user:#{doorkeeper_token.resource_owner_id}", expires_in: 25.hours) do
User.find(doorkeeper_token.resource_owner_id)
end
end
return @current_user
end
def current_user