Skip to content

Commit

Permalink
Revert "Always set header in batch mode" (lynndylanhurley#1161)
Browse files Browse the repository at this point in the history
This reverts commit 1c4e1d0.
  • Loading branch information
MaicolBen authored Aug 10, 2018
1 parent efa2cee commit 1c3520b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
15 changes: 3 additions & 12 deletions app/controllers/devise_token_auth/concerns/set_user_by_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,22 +135,13 @@ def update_auth_header
if @is_batch_request
auth_header = @resource.extend_batch_buffer(@token, @client_id)

# Do not return token for batch requests to avoid invalidated
# tokens returned to the client in case of race conditions.
# Use a blank string for the header to still be present and
# being passed in a XHR response in case of
# 304 Not Modified responses.
auth_header[DeviseTokenAuth.headers_names[:"access-token"]] = ' '
auth_header[DeviseTokenAuth.headers_names[:"expiry"]] = ' '

# update Authorization response header with new token
else
auth_header = @resource.create_new_auth_token(@client_id)
end

# update the response header
response.headers.merge!(auth_header)

# update the response header
response.headers.merge!(auth_header)
end
end # end lock
end # end ensure_pristine_resource
end
Expand Down
3 changes: 2 additions & 1 deletion test/controllers/demo_mang_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class DemoMangControllerTest < ActionDispatch::IntegrationTest
end

it 'should not return auth headers for second (batched) requests' do
assert_equal ' ', @second_access_token
refute @second_access_token
end
end

Expand Down Expand Up @@ -284,3 +284,4 @@ class DemoMangControllerTest < ActionDispatch::IntegrationTest
end
end
end

2 changes: 1 addition & 1 deletion test/controllers/demo_user_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class DemoUserControllerTest < ActionDispatch::IntegrationTest
end

it 'should not return auth headers for second (batched) requests' do
assert_equal ' ', @second_access_token
refute @second_access_token
end
end

Expand Down

0 comments on commit 1c3520b

Please sign in to comment.