User

interface User

A user holds the user's metadata and tokens for accessing App Services and Device Sync functionality.

User profile and custom data can be accessed using the extension functions User.profileAsBsonDocument and User.customDataAsBsonDocument.

The user is used to configure synchronized realms with SyncConfiguration.Builder.

See also

Types

Link copied to clipboard

A user's potential states.

Properties

Link copied to clipboard
abstract val accessToken: String

Returns the current access token for the user. If a user logs out, an empty access token is returned.

Link copied to clipboard
abstract val apiKeyAuth: ApiKeyAuth

Gives access to the ApiKeyAuth interface so that users can manage their API keys.

Link copied to clipboard
abstract val app: App

The App this user is associated with.

Link copied to clipboard
abstract val deviceId: String

Returns a unique identifier for the device the user logged in to.

Link copied to clipboard
abstract val functions: Functions

Returns a wrapper for invoking App Services Functions.

Link copied to clipboard
abstract val id: String

The server id of the user.

Link copied to clipboard

Returns a list of the user's identities as defined by the authentication providers enabled for this user.

Link copied to clipboard
abstract val identity: String

The server id of the user.

Link copied to clipboard
abstract val loggedIn: Boolean

Returns whether or not this user is still logged into the App Services Application.

Link copied to clipboard

Returns the provider type used to log the user in. If a user logs out, the authentication provider last used to log the user in will still be returned.

Link copied to clipboard
abstract val refreshToken: String

Returns the current refresh token for the user. If a user logs out an empty refresh token is returned.

Link copied to clipboard
abstract val state: User.State

The State this user is in.

Functions

Link copied to clipboard
fun <T> User.customData(serializer: KSerializer<T>): T?

Returns the custom user data associated with the user in the Realm App as T.

Link copied to clipboard
inline fun User.customDataAsBsonDocument(): BsonDocument?

Return the custom user data associated with the user in the Realm App as BsonDocument.

Link copied to clipboard
abstract suspend fun delete()

Permanently deletes this user from your Atlas App Services app.

Link copied to clipboard
abstract operator override fun equals(other: Any?): Boolean

Two Users are considered equal if they have the same user identity and are associated with the same app.

Link copied to clipboard
abstract suspend fun linkCredentials(credentials: Credentials): User

Links the current user with a new user identity represented by the given credentials.

Link copied to clipboard
abstract suspend fun logOut()

Log the user out of the Realm App. This will unregister them on the device and stop any synchronization to and from the users' Realms. Any Realms owned by the user will not be deleted from the device before User.remove is called.

Link copied to clipboard
fun <T> User.profile(serializer: KSerializer<T>): T

Returns the profile for this user as a T.

Link copied to clipboard
inline fun User.profileAsBsonDocument(): BsonDocument

Returns the profile for this user as BsonDocument.

Link copied to clipboard
abstract suspend fun refreshCustomData()

Re-fetch custom user data from the Realm App.

Link copied to clipboard
abstract suspend fun remove(): User

Removes the user and any Realms the user has from the device. No data is removed from the server.