correct rack::cache so it always punches through users with auth cookies
This commit is contained in:
parent
1725bf77a7
commit
8014d7fd25
|
@ -37,7 +37,7 @@ Discourse::Application.configure do
|
||||||
config.handlebars.precompile = true
|
config.handlebars.precompile = true
|
||||||
|
|
||||||
# this setting enable rack_cache so it caches various requests in redis
|
# this setting enable rack_cache so it caches various requests in redis
|
||||||
config.enable_rack_cache = false
|
config.enable_rack_cache = true
|
||||||
|
|
||||||
# allows users to use mini profiler
|
# allows users to use mini profiler
|
||||||
config.enable_mini_profiler = false
|
config.enable_mini_profiler = false
|
||||||
|
|
|
@ -4,7 +4,21 @@ if Rails.configuration.respond_to?(:enable_rack_cache) && Rails.configuration.en
|
||||||
|
|
||||||
url = DiscourseRedis.url
|
url = DiscourseRedis.url
|
||||||
|
|
||||||
Rails.configuration.middleware.insert 0, Rack::Cache,
|
class Rack::Cache::Discourse < Rack::Cache::Context
|
||||||
|
def initialize(app, options={})
|
||||||
|
@app = app
|
||||||
|
super
|
||||||
|
end
|
||||||
|
def call(env)
|
||||||
|
if CurrentUser.has_auth_cookie?(env)
|
||||||
|
@app.call(env)
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.configuration.middleware.insert 0, Rack::Cache::Discourse,
|
||||||
metastore: "#{url}/metastore",
|
metastore: "#{url}/metastore",
|
||||||
entitystore: "#{url}/entitystore",
|
entitystore: "#{url}/entitystore",
|
||||||
verbose: !Rails.env.production?
|
verbose: !Rails.env.production?
|
||||||
|
|
Loading…
Reference in New Issue