Docs Menu
Docs Home
/ /
Atlas Device SDKs
/
/

Manage Email/Password Users - C++ SDK

On this page

  • Register a New User
  • Log In or Log Out a User

When you enable the email/password provider in your Atlas App Services App, you can handle user authentication from client code by registering and logging in new user.

You can register a new user by calling the App.register_user() member function with the desired username and password.

auto appConfig = realm::App::configuration();
appConfig.app_id = APP_ID;
auto app = realm::App(appConfig);
auto userEmail = "testUser" + random_string() + "@example.com";
auto userPassword = "password1234";
app.register_user(userEmail, userPassword).get();

The C++ SDK does not yet support user confirmation or password reset, so you must configure the email/password provider to automatically confirm users. We do not recommend automatically confirming users in a production environment.

After you register a user, it is a separate step to log the user in.

auto user = app.login(realm::App::credentials::username_password(
userEmail, userPassword))
.get();

You can log out an authenticated user.

user.log_out().get();
← 
 →