From 0587875a75cf4d27a360f1c2b0498a83dabacfbd Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Sat, 30 Jan 2021 01:27:11 -0500 Subject: [PATCH] Fix current_resource_owner caching implementation --- app/controllers/api/base_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 0092b2ea..84954d1c 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -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