Bring your existing users #

View this page as Markdown

On this page

Start by choosing a sign-in method for returning users. Keep user records, roles, and teams in your database when you switch sign-in to Turn Zero Cloud. Each real user signs in afresh. Turn Zero Cloud creates their end-user record at first sign-in and offers no import of real users or their old passwords.

Use a workforce audience to let one company's staff sign in through its Microsoft Entra tenant or its OpenID Connect issuer.

What your AI does #

  • Adds sign-in to your app and checks which methods the realm offers.
  • Adds a first-sign-in route that verifies the session and finds every matching legacy account. It links only a single match that passes the app's ownership and eligibility checks.
  • Checks first and repeated sign-in, recovery, and access after a membership changes.

What you need #

  • Your existing user database, with account IDs, email verification history, and any roles or team memberships your app grants.
  • A development environment with synthetic legacy records and test end users. Test sign-in with test end users shows how to create and sign in a fixture.
  • An app-owned recovery process that can verify control of the old account independently of the new sign-in.

Before your AI starts #

Choose the sign-in methods returning users can use. Enable emailed codes if you plan to use the password-to-code route. In an invitation-only app, invite each person and have them open the invitation before signing in with its address.

Microsoft Entra and company OpenID Connect are unavailable when the app’s audience or the realm’s creation setting makes sign-up invitation-only. A workforce realm offers only the work-account method that matches the audience's tenant ID or issuer address. Use entra for a Microsoft Entra tenant ID or oidc for a company issuer whose address matches exactly. Follow work-account sign-in for that realm and keep your application's recovery process available.

Set your recovery policy before linking. Require independent proof of the old account where an address is shared, changed, reassigned, or untrusted, or where the account is privileged. An emailed code proves current mailbox control. Your recovery process establishes ownership of the old account in those cases.

Steps #

1. Offer returning users a sign-in method #

Where enabled, offer emailed codes to former password users at their old account address. If enabled, Google or GitHub can also work when the provider returns the same verified address. Let each person complete any second step the provider asks for. Where enabled, a passkey is another sign-in method. A passkey from the old hostname cannot sign a person in on the new hostname. When the new realm offers emailed codes and passkeys, have the person sign in by emailed code before they register a passkey there.

An Entra address can be unverified. Company OpenID Connect addresses are always unverified. An Apple private relay address can differ from the old address. If a returning person has a missing, mismatched or unverified address, use the recovery checks below. Leave their legacy records intact.

2. Verify the new session and find the old record #

On your server, use the keyless Account client in the verified-email example to call verifySession. The verification route returns the user ID and addresses. Local verification gives the user ID, realm ID and verdict. It supplies no addresses or sign-in methods. For linking by verified address, use the verification route.

If verification fails or the user is suspended, leave the old record untouched. Use an existing link for a live user and check current permissions. For a first link, use verdict.user.addresses.filter((address) => address.verified === true).map((address) => address.email) to collect every verified email instead of the single address the example returns.

Find every distinct legacy account that matches any of those addresses before checking eligibility. Use the same comparison for returned and stored addresses. Keep plus tags and dots as stored. Count disabled, stale, privileged and otherwise ineligible records in the match set.

Continue only when the full set contains exactly one account and that account passes your ownership and eligibility checks. Check the old account's current standing against your app's rules and confirm the returning person owns it. Confirm its old address was verified and that your recovery policy still trusts it. With zero matches, multiple matches, or a failed check, leave the accounts unlinked and use the recovery process below.

Store a one-to-one mapping in your application's database from the verified Turn Zero user ID to the old account ID. Keep separate mappings for separate environments. Make both IDs unique within each mapping and save the link in one transaction. A repeat for the same pair uses the existing row. A conflict with either ID stops the link and goes to the app owner.

Use the realm's user list to check who has an account there, and the invitation list to check which invitations were used. To confirm that a returning user can reach their old account, check the link in your application's database and test their current permissions.

Keep roles and team memberships in tables your application owns. On each signed-in request, use the verified user ID to find the linked account and check its current permissions. Read those permissions from your app's records and allow only the access they grant. Changing the sign-in method keeps the same authorization rules.

4. Try one returning user #

For a simulated test, give the legacy account customer-42 the verified address reader@example.test and member access to the North team. Have session verification return usr-demo and that address with verified: true. Check that two sign-ins use one link and return the same current access.

For a browser pilot, create a test end user in development as Test sign-in with test end users shows. Seed a synthetic legacy row with the exact test address, such as migration-pilot@synthetic.turnzero.ai. Use the test user's email from the test_end_users list. Leave the addresses on real users' legacy records unchanged.

The test page needs the platform operator's test-end-user setting to be on and the app's realm to have a usable sign-in method. If the realm has no usable method, set one up with Add sign-in to your app. The test page provides its own code form. An unexpired test user already exists in the realm and can sign in without an invitation under an invited audience.

Open test_signin_page from the creation response and get its code with tzcloud_read_test_signin_code. Use the actual verified user ID after sign-in.

Test mail delivery separately on the ordinary development sign-in page with a team-controlled address. If sign-up is invitation-only, open its invitation before signing in. To test ordinary workforce sign-in, use an authorized account from the declared Microsoft Entra tenant or company issuer. Submitting the manifest applies the workforce audience to every environment the app has, so first have the owner agree who can still sign in and have an authorized person test the new route. The switch to a workforce audience takes effect at submission and starts sign-out for sessions outside the chosen tenant or issuer.

Before moving production sign-in, test a conflicting link, a duplicate with one eligible match, and access after membership is revoked. Remove the pilot mappings, synthetic legacy records, and test end users when the checks finish. If you created an ordinary development user for the mail-delivery test, confirm with the owner that this user's data can be deleted. Use tzcloud_delete_end_user for development and have the owner approve the deletion in the browser. See Check development before promoting.

Expected result #

A returning person signs in afresh and reaches their old account after the ownership and eligibility checks pass. Repeated sign-in uses the same link. The application applies the permissions it holds today. An invalid session, unresolved match or failed ownership check leaves legacy data closed.

Refusals #

What you see Cause Remedy
The verification route refuses or gives no answer The session ended, or the service is unavailable Leave the old record untouched and keep access closed. Ask the person to sign in again if their session ended, or retry verification after the service returns.
The provider address differs, is unverified or is absent The address cannot prove the old account Leave the accounts unlinked. Where email codes are enabled and the old address is still trusted, the person can try a code there. Apply the same full-match, ownership and eligibility checks.
Multiple legacy accounts match, or the old account needs independent proof The address alone cannot settle ownership Leave the accounts unlinked. Send the person through your application's recovery process for independent proof of old-account control. An emailed code alone is insufficient.
Either ID is already linked to someone else A link already uses that ID Keep both records as they are. The app owner resolves the conflict using proof of the old account.