Link User Identities - Node.js SDK
Atlas Device SDKs are deprecated. Refer to the deprecation page for details.
Overview
Realm provides many authentication providers to log users into your app. Each provider creates a unique user identity. Realm lets you merge multiple credentials into one user identity.
Example
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.
You can link identities using linkCredentials(). This links authentication providers
to a logged-in User
object.
async function linkAccounts(user, email, password) { const emailPasswordUserCredentials = Realm.Credentials.emailPassword( email, password ); const linkedAccount = await user.linkCredentials( emailPasswordUserCredentials ); return linkedAccount; }
async function linkAccounts( user: Realm.User, email: string, password: string ) { const emailPasswordUserCredentials = Realm.Credentials.emailPassword( email, password ); const linkedAccount = await user.linkCredentials( emailPasswordUserCredentials ); return linkedAccount; }