Manage Users - Web SDK
On this page
You must use App Services in the context of a user. Users are associated with one or more authentication providers. You can also assign data access rules to users to constrain what data they access. Use Realm Web SDK to perform the following authentication and user management actions:
Creation of new user accounts
User log-in and log-out
Multiple users logged on at the same time on the same device
Linking user accounts from different providers
Providing custom user data
When you have a logged-in user, SDK methods enable you to:
Run a backend function as the logged-in user
Create and Delete Users
For all authentication providers other than email/password authentication, App Services automatically creates a user the first time a user authenticates. If a user authenticates via more than one method, you can link these user identities to a single user.
You can delete users. Deleting a user deletes metadata attached to the user, but does not delete user-created data from the backend.
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, your own custom function, or custom JWT user management.
Enable anonymous users to let users access your App Services App without persisting user data.
For further information, see Authenticate Users.
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.
The Web SDK stores these tokens in the browser storage.
Read and Update Custom User Data
You can associate custom data with a user,
such as a preferred language or local timezone, and read it from your client
application. A user 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.