Manage Users - C++ SDK
On this page
When you use Atlas App Services to back your client app, you get access to a user object. Use C++ SDK methods with this user object to conveniently:
Create and delete users
Log users in and out
Create and update custom user data
Create and Delete Users
For all authentication providers other than email/password authentication, App Services automatically creates a user object the first time a user authenticates. With email/password authentication, your app must manually register a user.
The C++ SDK does not yet have the ability to delete users through
the SDK. You can delete users from the server using the App Services
Admin API delete a user
endpoints. You could optionally
create an Atlas Function that uses the Admin API to
delete a user, and call the function from the SDK.
Log Users In and Out
Use one or more authentication providers to log users in and out of your client app. You can:
Log users in with an existing social account, such as Apple, Facebook, or Google.
Create new user accounts with App Services email/password management, or your own custom function or custom JWT user management.
Enable anonymous users to let users access your App Services App without persisting user data.
When you have a logged-in user, SDK methods enable you to:
Open a synced realm with the user's configuration object
Run a backend function as the logged-in user
On successful login, the C++ SDK caches credentials on the device. You can bypass the login flow and access the cached user. Use this to open a realm or call a function upon subsequent app opens.
User Sessions
App Services manages sessions with access tokens and refresh tokens. Client SDKs supply the logic to manage tokens and provide them with requests.
Realm uses refresh tokens to automatically update a user's access token when it expires. However, Realm does not automatically refresh the refresh token. When the refresh token expires, the SDK can no longer get an updated access token and the device cannot sync until the user logs in again.
For more information on managing user sessions and tokens, see User Sessions in the App Services documentation.
Read and Update Custom User Data
You can associate custom data with a user object,
such as a preferred language or local timezone, and read it from your client
application. A user object has a customData
property that you can use
to access custom user data.
To create and update custom user data, you must access your MongoDB data source directly. App Services does not offer a SDK method to create or update this custom user data; it's a read-only property.