Make sign up Magic Links work across devices
Previously if someone started signing in on their phone, but finished it on their laptop, they'd end up on the menu screen with no account. Bu tracking the purpose of a Magic Link we can always direct the user to sign up if they requested a magic link through sign up. This also makes the logic for changing the copy in the email more robust.
This commit is contained in:
@@ -9,17 +9,32 @@ class Sessions::MagicLinksControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test "create" do
|
||||
test "create with sign in code" do
|
||||
identity = identities(:kevin)
|
||||
magic_link = MagicLink.create!(identity: identity)
|
||||
|
||||
untenanted do
|
||||
post session_magic_link_url, params: { code: magic_link.code }
|
||||
end
|
||||
|
||||
assert_response :redirect
|
||||
assert cookies[:session_token].present?
|
||||
assert_not MagicLink.exists?(magic_link.id), "The magic link should be consumed"
|
||||
assert_response :redirect
|
||||
assert cookies[:session_token].present?
|
||||
assert_redirected_to landing_path, "Should redirect to after authentication path"
|
||||
assert_not MagicLink.exists?(magic_link.id), "The magic link should be consumed"
|
||||
end
|
||||
end
|
||||
|
||||
test "create with sign up code" do
|
||||
identity = identities(:kevin)
|
||||
magic_link = MagicLink.create!(identity: identity, purpose: :sign_up)
|
||||
|
||||
untenanted do
|
||||
post session_magic_link_url, params: { code: magic_link.code }
|
||||
|
||||
assert_response :redirect
|
||||
assert cookies[:session_token].present?
|
||||
assert_redirected_to new_signup_completion_path, "Should redirect to signup completion"
|
||||
assert_not MagicLink.exists?(magic_link.id), "The magic link should be consumed"
|
||||
end
|
||||
end
|
||||
|
||||
test "create with invalid code" do
|
||||
|
||||
Reference in New Issue
Block a user