Linking user while SAML login flow

Hi community,

I integrated SAML (Salesforce is the IdP) into our Auth0 environment.
As we have all users in Auth0 already and SAML creates a new Identity I created a Script (action) that finds the existing customer when the SAML identity gets created, and links them together. So the real user is the primary one and the SAML user is the secondary.

Everything works, but there is a problem when the SAML user gets created for the first time.
The linking works, but with the first login, our React app receives the SAML user and not the existing one where it got merged in. If the user has merged already it works fine. It’s just the first call.

My idea was, after the linking happened, to redirect to the original source site including the parameters with “api.redirect.sendUserTo({originalURL})” in the action.
When I try this by adding the full URL manually in the action (hardcoded) it works. But I have no idea where to get the full URL from. I tried “event.transaction.redirect_uri” already. But this did not help.

Or maybe somebody has a better idea than redirecting to the source URL.