Manage Email/Password Users - .NET SDK

If you have enabled the email/password provider in your Realm app, you can register a new account, confirm an email address, and reset a user's password in the client code.

To register a new user, pass a user-provided email and password to the RegisterUserAsync() method:

await app.EmailPasswordAuth.RegisterUserAsync(userEmail, "sekrit");

To confirm a newly-created user, pass a confirmation token and tokenId to the ConfirmUserAsync() mehtod.

Use Deep Links in Mobile Apps

Mobile applications can handle email confirmation directly in the app by configuring deep linking in Android, universal links in iOS, and/or URI handlers for the Universal Windows Platform (UWP).

await app.EmailPasswordAuth.ConfirmUserAsync("<token>", "<token-id>");

To reset a user's password, first send the user a password reset email:

await app.EmailPasswordAuth.SendResetPasswordEmailAsync(userEmail);

Password reset emails contain two values, token and tokenId. To complete the password reset flow, you can reset the user's password on the client or by calling a custom function on the backend.

To reset the password on the client, your UI should prompt the user to enter a new password and the token and tokenId values. You pass these values to the ResetPasswordAsync() method:

await app.EmailPasswordAuth.ResetPasswordAsync(
myNewPassword, "<token>", "<token-id>");

To access the token and tokenId values sent in the password reset email, you can use a custom password reset email containing an Android deep link or iOS universal link.

If you have defined a backend function to reset the user's password, you pass the user's email address and new password to the CallResetPasswordFunctionAsync() method. The function will likely require additional parameters, as shown below:

await app.EmailPasswordAuth.CallResetPasswordFunctionAsync(
userEmail, myNewPassword,
Give Feedback