From a9823ab59aefffd0c746c05b7d87075f11c60cbc Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 28 Oct 2015 17:16:56 -0400 Subject: [PATCH] FIX: Use a cookie to bypass the anon cache --- app/controllers/users/omniauth_callbacks_controller.rb | 1 + lib/middleware/anonymous_cache.rb | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 39209b417..a7fc7aaf4 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -57,6 +57,7 @@ class Users::OmniauthCallbacksController < ApplicationController complete_response_data if provider && provider.full_screen_login + cookies['_bypass_cache'] = true flash[:authentication_data] = @auth_result.to_client_hash.to_json redirect_to @origin else diff --git a/lib/middleware/anonymous_cache.rb b/lib/middleware/anonymous_cache.rb index a65eb2df1..a79b42256 100644 --- a/lib/middleware/anonymous_cache.rb +++ b/lib/middleware/anonymous_cache.rb @@ -64,8 +64,13 @@ module Middleware CurrentUser.has_auth_cookie?(@env) end + def no_cache_bypass + request = Rack::Request.new(@env) + request.cookies['_bypass_cache'].nil? + end + def cacheable? - !!(!has_auth_cookie? && get?) + !!(!has_auth_cookie? && get? && no_cache_bypass) end def cached