Skip to content

Commit af9c1b6

Browse files
committed
Return the session cookie
We had a call about this. In short, we could reuse access tokens but then the user would see access tokens for every mobile device they have without any indication as to what is going on. So, since this really is just logging in instead of an integration which seems to be the primary purpose of access tokens, we can just use our regular session cookie for authentication.
1 parent 0981480 commit af9c1b6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

app/controllers/sessions/magic_links_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ def code
2222
end
2323

2424
def respond_to_valid_code_from(magic_link)
25+
start_new_session_for magic_link.identity
26+
2527
respond_to do |format|
2628
format.html do
27-
start_new_session_for magic_link.identity
2829
redirect_to after_sign_in_url(magic_link)
2930
end
3031

3132
format.json do
32-
new_access_token = magic_link.identity.access_tokens.create!(permission: :write)
33-
render json: { access_token: new_access_token.token }
33+
render json: { session_token: cookies[:session_token] }
3434
end
3535
end
3636
end

test/controllers/api_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ApiTest < ActionDispatch::IntegrationTest
2020
untenanted do
2121
post session_magic_link_path(format: :json), params: { code: magic_link.code }
2222
assert_response :success
23-
assert @response.parsed_body["access_token"].present?
23+
assert @response.parsed_body["session_token"].present?
2424
end
2525
end
2626

0 commit comments

Comments
 (0)