User Data Sync
A key feature of the API server’s authentication system is its ability to provide a seamless experience for users who start using the app anonymously and later decide to create a permanent account. All of their data, such as saved headlines and followed topics, is automatically carried over.
The Guest User Flow
Section titled “The Guest User Flow”-
Anonymous Sign-In: When a new user opens the mobile app for the first time, the app can perform an “anonymous sign-in”. The API server creates a temporary
guestUser
account and returns an authentication token for it. -
Data Accumulation: The guest user can now use the app normally. They can save headlines, follow topics, and customize their settings. All this data is associated with their temporary
guestUser
ID.
The Conversion Process
Section titled “The Conversion Process”When the guest user decides to create a permanent account (e.g., by providing their email and verifying a code), the AuthService
handles the conversion intelligently:
-
Email Verification: The user provides an email and completes the standard verification process.
-
Account Check: The server checks if a permanent account with the verified email already exists.
-
Scenario A: Account Already Exists: If a user with that email is found, the server signs them into their existing account. The temporary
guestUser
account and its associated data are deleted, and a new token for the permanent account is issued. This prevents account duplication. -
Scenario B: No Account Exists: If no account is found for the email, the server converts the existing
guestUser
record into astandardUser
. It updates the user’s record with the verified email and changes their role.
-