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:
Stanko K.R.
2025-11-29 12:36:00 +01:00
parent e302e79b55
commit 2311efd03e
10 changed files with 56 additions and 17 deletions
@@ -9,9 +9,9 @@ class Sessions::MagicLinksController < ApplicationController
end
def create
if identity = MagicLink.consume(code)
start_new_session_for identity
redirect_to after_authentication_url
if magic_link = MagicLink.consume(code)
start_new_session_for magic_link.identity
redirect_to after_sign_in_url(magic_link)
else
redirect_to session_magic_link_path, alert: "Try another code."
end
@@ -21,4 +21,12 @@ class Sessions::MagicLinksController < ApplicationController
def code
params.expect(:code)
end
def after_sign_in_url(magic_link)
if magic_link.for_sign_up?
new_signup_completion_path
else
after_authentication_url
end
end
end