How it works
tiun identifies users without passwords or OAuth. Identity is established through email plus one-time passcode (OTP) verification, all handled by the SDK.
Two entry points
There are two ways a user can become authenticated:
Through checkout — authentication is built into the payment flow. The user enters their email (and completes OTP where needed) as part of checkout, so they're signed in the moment the purchase completes.
Through dedicated login — call
tiun.login()to open the login overlay without starting a purchase. Useful for returning users who already have a subscription.
Login flow
Returning user. They enter their email. Because a phone number is already linked to the account, the OTP is sent to their phone via SMS.
New user. They enter their email and phone number. The OTP is sent to the phone to verify and link it.
Fallback. If the SMS doesn't arrive, the overlay offers to resend the code to the email instead.
After a successful flow, the user is available via tiun.getUser() — see User object for the shape and what each field means.
Session persistence
tiun manages sessions for you. On the same browser, returning visitors are recognized automatically. When the page loads and a session is restored, the userChange event fires with event: 'init' so your UI can align without extra calls. See Subscriptions for the full lifecycle.
Logout
Call tiun.logout() to clear the session on the current device. After logout, treat the user as unauthenticated until they sign in or complete checkout again.
Last updated
Was this helpful?