On this page
Atlas App Services provides multiple authentication providers to log users into your app. Each provider creates a unique user identity. App Services lets you merge multiple credentials into one user identity.
User linkedCredentialUser = await user.linkCredentials(additionalCredentials);
Consider an application that offers anonymous login. This allows users to explore the app without
registering. If users like the application, they create permanent
accounts. They sign up with SSO or email/password authentication. By default,
this creates a new
User object. The app must link the new
identity with the original User.
We must first register the new email/password user before linking.
// on app start without registration User anonymousUser = await app.logIn(Credentials.anonymous()); // ... user interacts with app //... user decides to sign up for app with email/password auth EmailPasswordAuthProvider authProvider = EmailPasswordAuthProvider(app); await authProvider.registerUser(USERNAME, PASSWORD); // link email/password credentials to anonymous user's credentials User linkedCredentialUser = await anonymousUser .linkCredentials(Credentials.emailPassword(USERNAME, PASSWORD));