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

State
Link copied to clipboard
enum State : Enum<User.State>

A user's potential states.

Functions

delete
Link copied to clipboard
abstract suspend fun delete()

Permanently deletes this user from your Atlas App Services app.

equals
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.

linkCredentials
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.

logOut
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.

refreshCustomData
Link copied to clipboard
abstract suspend fun refreshCustomData()

Re-fetch custom user data from the Realm App.

remove
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.

Properties

accessToken
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.

apiKeyAuth
Link copied to clipboard
abstract val apiKeyAuth: ApiKeyAuth

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

app
Link copied to clipboard
abstract val app: App

The App this user is associated with.

deviceId
Link copied to clipboard
abstract val deviceId: String

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

functions
Link copied to clipboard
abstract val functions: Functions

Returns a wrapper for invoking App Services Functions.

id
Link copied to clipboard
abstract val id: String

The server id of the user.

identities
Link copied to clipboard
abstract val identities: List<UserIdentity>

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

identity
Link copied to clipboard
abstract val identity: String

The server id of the user.

loggedIn
Link copied to clipboard
abstract val loggedIn: Boolean

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

provider
Link copied to clipboard
abstract val provider: AuthenticationProvider

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.

refreshToken
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.

state
Link copied to clipboard
abstract val state: User.State

The State this user is in.

Extensions

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

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

customDataAsBsonDocument
Link copied to clipboard
inline fun User.customDataAsBsonDocument(): <ERROR CLASS>?

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

profile
Link copied to clipboard
fun <T> User.profile(serializer: <ERROR CLASS><T>): T
inline fun <T> User.profile(): T

Returns the profile for this user as a T.

profileAsBsonDocument
Link copied to clipboard
inline fun User.profileAsBsonDocument(): <ERROR CLASS>

Returns the profile for this user as BsonDocument.