Skip to content

Commit 0b253ba

Browse files
committed
has_auth_cookie was not implemented correctly, causing logged in requests to be handled as though they are anon
1 parent 719ec1b commit 0b253ba

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/auth/default_current_user_provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def is_api?
7373

7474
def has_auth_cookie?
7575
request = Rack::Request.new(@env)
76-
cookie = request.cookies[CURRENT_USER_KEY]
76+
cookie = request.cookies[TOKEN_COOKIE]
7777
!cookie.nil? && cookie.length == 32
7878
end
7979
end

spec/components/middleware/anonymous_cache_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def new_helper(env={})
1919
it "is false for non GET" do
2020
new_helper("ANON_CACHE_DURATION" => 10, "REQUEST_METHOD" => "POST").cacheable?.should be_false
2121
end
22+
23+
it "is false if it has an auth cookie" do
24+
new_helper("HTTP_COOKIE" => "jack=1; _t=#{"1"*32}; jill=2").cacheable?.should be_false
25+
end
2226
end
2327

2428
context "cached" do

0 commit comments

Comments
 (0)