Skip to content

Commit 9ac9f04

Browse files
djpremierThiagoAnunciacao
authored andcommitted
πŸ› Not update cookies when is a batch request (lynndylanhurley#1577)
* πŸ› Not update cookies when is a batch request * βœ… Fix confirmations controller test
1 parent 58cb639 commit 9ac9f04

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

β€Žapp/controllers/devise_token_auth/concerns/set_user_by_token.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def refresh_headers
154154
# update the response header
155155
response.headers.merge!(_auth_header_from_batch_request)
156156

157-
# set a server cookie if configured
158-
if DeviseTokenAuth.cookie_enabled
157+
# set a server cookie if configured and is not a batch request
158+
if DeviseTokenAuth.cookie_enabled && !@is_batch_request
159159
set_cookie(_auth_header_from_batch_request)
160160
end
161161
end # end lock

β€Žapp/controllers/devise_token_auth/confirmations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def show
2222
redirect_to_link = signed_in_resource.build_auth_url(redirect_url, redirect_headers)
2323
else
2424
redirect_to_link = DeviseTokenAuth::Url.generate(redirect_url, redirect_header_options)
25-
end
25+
end
2626

2727
redirect_to(redirect_to_link)
2828
else

β€Žtest/controllers/devise_token_auth/confirmations_controller_test.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,12 @@ def token_and_client_config_from(body)
202202

203203
describe 'failure' do
204204
test 'user should not be confirmed' do
205-
assert_raises(ActionController::RoutingError) do
206-
get :show, params: { confirmation_token: 'bogus' }
207-
end
205+
get :show,
206+
params: { confirmation_token: 'bogus',
207+
redirect_url: @redirect_url }
208+
209+
assert_redirected_to(/^#{@redirect_url}/)
210+
208211
@resource = assigns(:resource)
209212
refute @resource.confirmed?
210213
end

0 commit comments

Comments
Β (0)