Manage Email/Password Users - C++ SDK
On this page
Atlas Device SDKs are deprecated. Refer to the deprecation page for details.
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.
Register a 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.
Log In or Log Out a User
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();