diff --git a/lib/clearance/session.rb b/lib/clearance/session.rb index 1e87a5089..bcdc46da1 100644 --- a/lib/clearance/session.rb +++ b/lib/clearance/session.rb @@ -7,16 +7,15 @@ def initialize(env) end def add_cookie_to_headers(headers) - if signed_in? - Rack::Utils.set_cookie_header!( - headers, REMEMBER_TOKEN_COOKIE, - :value => current_user.remember_token, - :expires => Clearance.configuration.cookie_expiration.call, - :secure => Clearance.configuration.secure_cookie, - :httponly => Clearance.configuration.httponly, - :path => '/' - ) - end + Rack::Utils.set_cookie_header!( + headers, + REMEMBER_TOKEN_COOKIE, + :value => remember_token, + :expires => Clearance.configuration.cookie_expiration.call, + :secure => Clearance.configuration.secure_cookie, + :httponly => Clearance.configuration.httponly, + :path => '/' + ) end def current_user @@ -27,6 +26,7 @@ def current_user def sign_in(user) @current_user = user + cookies[REMEMBER_TOKEN_COOKIE] = @current_user.remember_token end def sign_out @@ -57,8 +57,8 @@ def remember_token end def with_remember_token - if token = remember_token - yield token + if remember_token + yield remember_token end end end diff --git a/lib/clearance/testing/helpers.rb b/lib/clearance/testing/helpers.rb index a1aeeb2d4..2ac1c47cc 100644 --- a/lib/clearance/testing/helpers.rb +++ b/lib/clearance/testing/helpers.rb @@ -15,7 +15,7 @@ def sign_in_as(user) end def sign_out - @controller.current_user = nil + @controller.sign_out end end end