This class represents a user in a Atlas App Services application. The credentials are provided by various 3rd party providers (Facebook, Google, etc.). A user can log in to the server and, if access is granted, it is possible to synchronize the local and the remote Realm. Moreover, synchronization is halted when the user is logged out. It is possible to persist a user. By retrieving a user, there is no need to log in to the 3rd party provider again. Persisting a user between sessions, the user's credentials are stored locally on the device, and should be treated as sensitive data.
Namespace: Realms.Sync Assembly: Realm.dll Syntaxpublic class User : IEquatable<User>
Properties | Edit this page View Source AccessToken
Gets this user's access token. This is the user's credential for accessing MongoDB Atlas data and should be treated as sensitive information.
Declarationpublic string AccessToken { get; }
Property Value Type Description string
A unique string that can be used to represent this user before the server.
| Edit this page View Source ApiKeysGets a User.ApiKeyClient instance that exposes functionality for managing user API keys.
Declarationpublic User.ApiKeyClient ApiKeys { get; }
Property Value See Also | Edit this page View Source App
Gets the app with which this user is associated.
Declaration Property Value Type Description AppAn App instance that owns this user.
| Edit this page View Source DeviceIdGets a unique identifier for the device the user logged in to.
Declarationpublic string DeviceId { get; }
Property Value Type Description string
A unique string that identifies the current device.
| Edit this page View Source FunctionsGets a User.FunctionsClient instance that exposes functionality for calling remote Atlas Functions.
Declarationpublic User.FunctionsClient Functions { get; }
Property Value See Also | Edit this page View Source Id
Gets the Id of this user in Atlas App Services.
Declarationpublic string Id { get; }
Property Value Type Description string
A string that uniquely identifies that user.
| Edit this page View Source IdentitiesGets a collection of all identities associated with this user.
Declarationpublic UserIdentity[] Identities { get; }
Property Value | Edit this page View Source Profile
Gets the profile information for that user.
Declarationpublic UserProfile Profile { get; }
Property Value Type Description UserProfile
A UserProfile object, containing information about the user's name, email, and so on.
| Edit this page View Source ProviderGets a value indicating which Credentials.AuthProvider this user logged in with.
Declaration[Obsolete("User.Provider wasn't working consistently and will be removed in a future version. You can get the provider of the user identity instead.")]
public Credentials.AuthProvider Provider { get; }
Property Value | Edit this page View Source RefreshToken
Gets this user's refresh token. This is the user's credential for accessing MongoDB Atlas data and should be treated as sensitive information.
Declarationpublic string RefreshToken { get; }
Property Value Type Description string
A unique string that can be used for refreshing the user's credentials.
| Edit this page View Source StateGets the current state of the user.
Declarationpublic UserState State { get; }
Property Value Type Description UserState
A value indicating whether the user is active, logged out, or an error has occurred.
Methods | Edit this page View Source Equals(User?)Determines whether this instance and another User instance are equal by comparing their identities.
Declarationpublic bool Equals(User? other)
Parameters Type Name Description User other
The User instance to compare with.
Returns Type Description booltrue if the two instances are equal; false otherwise.
| Edit this page View Source GetCustomData()Gets the custom user data associated with this user in the Realm app.
Declarationpublic BsonDocument? GetCustomData()
Returns Type Description BsonDocument
A document containing the user data.
See Also | Edit this page View Source GetCustomData<T>()Gets the custom user data associated with this user in the Realm app and parses it to the specified type.
Declarationpublic T? GetCustomData<T>() where T : class
Returns Type Description T
A document containing the user data.
Type Parameters Name Description TThe managed type that matches the shape of the custom data documents.
See Also | Edit this page View Source GetMongoClient(string)Gets a MongoClient instance for accessing documents in a MongoDB database.
Declarationpublic MongoClient GetMongoClient(string serviceName)
Parameters Type Name Description string serviceName
The name of the service as configured on the server.
Returns Type Description MongoClientA MongoClient instance that can interact with the databases exposed in the remote service.
| Edit this page View Source LinkCredentialsAsync(Credentials)Links the current user with a new user identity represented by the given credentials.
Declarationpublic Task<User> LinkCredentialsAsync(Credentials credentials)
Parameters Type Name Description Credentials credentials
The credentials to link with the current user.
Returns Type Description Task<User>An awaitable Task<TResult> representing the remote link credentials operation. Upon successful completion, the task result will contain the user to which the credentials were linked.
ExamplesThe following snippet shows how to associate an email and password with an anonymous user allowing them to login on a different device.
var app = App.Create("app-id")
var user = await app.LogInAsync(Credentials.Anonymous());
// This step is only needed for email password auth - a password record must exist
// before you can link a user to it.
await app.EmailPasswordAuth.RegisterUserAsync("email", "password");
await user.LinkCredentialsAsync(Credentials.EmailPassword("email", "password"));
| Edit this page View Source LogOutAsync()
Removes the user's local credentials and attempts to invalidate their refresh token from the server.
Declarationpublic Task LogOutAsync()
Returns Type Description Task
An awaitable Task that represents the remote logout operation.
| Edit this page View Source RefreshCustomDataAsync()Re-fetch the user's custom data from the server.
Declarationpublic Task<BsonDocument?> RefreshCustomDataAsync()
Returns Type Description Task<BsonDocument>
An awaitable Task<TResult> that represents the remote refresh operation. The result is a MongoDB.Bson.BsonDocument containing the updated custom user data. The value returned by GetCustomData() will also be updated with the new information.
| Edit this page View Source RefreshCustomDataAsync<T>()Re-fetch the user's custom data from the server.
Declarationpublic Task<T?> RefreshCustomDataAsync<T>() where T : class
Returns Type Description Task<T>
An awaitable Task<TResult> that represents the remote refresh operation. The result is an object containing the updated custom user data. The value returned by GetCustomData<T>() will also be updated with the new information.
Type Parameters Name Description TThe managed type that matches the shape of the custom data documents.
| Edit this page View Source ToString()Returns a string that represents the current object.
Declarationpublic override string ToString()
Returns Type Description string
A string that represents the current object.
Overrides Events | Edit this page View Source ChangedOccurs when a property value changes.
Declarationpublic event EventHandler? Changed
Event Type Operators | Edit this page View Source operator ==(User?, User?)
Determines whether two User instances are equal.
Declarationpublic static bool operator ==(User? user1, User? user2)
Parameters Type Name Description User user1
The first user to compare.
User user2The second user to compare.
Returns Type Description booltrue
if the two instances are equal; false
otherwise.
Determines whether two User instances are different.
Declarationpublic static bool operator !=(User? user1, User? user2)
Parameters Type Name Description User user1
The first user to compare.
User user2The second user to compare.
Returns Type Description booltrue
if the two instances are different; false
otherwise.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4