Realm C++ SDK main@552ddd11d8a568e4d40be11ea88bbd0534f5e2d6
Public Types | Public Member Functions | Public Attributes | List of all members

realm::user Struct Reference

#include <app.hpp>

Public Types

enum class  state : uint8_t { logged_out , logged_in , removed }
 

Public Member Functions

 user (const user &)=default
 
 user (user &&)=default
 
useroperator= (const user &)=default
 
useroperator= (user &&)=default
 
 user (std::shared_ptr< SyncUser > user)
 
bool is_logged_in () const
 
std::string identifier () const
 
state state () const
 
std::string access_token () const
 
std::string refresh_token () const
 
struct internal::bridge::sync_manager sync_manager () const
 
db_config flexible_sync_configuration () const
 
void log_out (std::function< void(std::optional< app_error >)> &&callback) const
 
std::future< void > log_out () const
 
std::optional< std::string > custom_data () const
 
void call_function (const std::string &name, const std::string &args_ejson, std::function< void(std::optional< std::string >, std::optional< app_error >)> callback) const
 
std::future< std::optional< std::string > > call_function (const std::string &name, const std::string &args_ejson) const
 
void refresh_custom_user_data (std::function< void(std::optional< app_error >)> callback)
 
std::future< void > refresh_custom_user_data () const
 

Public Attributes

std::shared_ptr< SyncUser > m_user
 

Detailed Description

A User instance represents a single Realm App user account.

A user may have one or more credentials associated with it. These credentials uniquely identify the user to the authentication provider, and are used to sign into a MongoDB Realm user account.

User objects can be accessed from any thread.

Member Enumeration Documentation

◆ state

enum class realm::user::state : uint8_t
strong

The state of the user object.

Member Function Documentation

◆ access_token()

std::string realm::user::access_token ( ) const

The user's refresh token used to access the Realm Application.

This is required to make HTTP requests to MongoDB Realm's REST API for functionality not exposed natively. It should be treated as sensitive data.

◆ call_function() [1/2]

std::future< std::optional< std::string > > realm::user::call_function ( const std::string &  name,
const std::string &  arguments 
) const

Calls the Atlas App Services function with the provided name and arguments.

Parameters
nameThe name of the Atlas App Services function to be called.
argumentsThe string represented extended json to be provided to the function.
callbackThe completion handler to call when the function call is complete. This handler is executed on the thread the method was called from.

Calls the Atlas App Services function with the provided name and arguments.

Parameters
nameThe name of the Atlas App Services function to be called.
argumentsThe BsonArray of arguments to be provided to the function.
callbackThe completion handler to call when the function call is complete. This handler is executed on the thread the method was called from.

◆ call_function() [2/2]

void realm::user::call_function ( const std::string &  name,
const std::string &  args_ejson,
std::function< void(std::optional< std::string >, std::optional< app_error >)>  callback 
) const

Calls the Atlas App Services function with the provided name and arguments.

Parameters
nameThe name of the Atlas App Services function to be called.
argumentsThe string represented extended json to be provided to the function.
callbackThe completion handler to call when the function call is complete. This handler is executed on the thread the method was called from.

◆ custom_data()

std::optional< std::string > realm::user::custom_data ( ) const

The custom data of the user. This is configured in your Atlas App Services app.

◆ identifier()

std::string realm::user::identifier ( ) const

The unique MongoDB Realm string identifying this user. Note this is different from an identitiy: A user may have multiple identities but has a single indentifier. See RLMUserIdentity.

◆ log_out()

void realm::user::log_out ( std::function< void(std::optional< app_error >)> &&  callback) const

Logs out the current user

The users state will be set to Removed is they are an anonymous user or LoggedOut if they are authenticated by an email / password or third party auth clients If the logout request fails, this method will still clear local authentication state.

◆ refresh_custom_user_data() [1/2]

std::future< void > realm::user::refresh_custom_user_data ( ) const

Refresh a user's custom data. This will, in effect, refresh the user's auth session.

◆ refresh_custom_user_data() [2/2]

void realm::user::refresh_custom_user_data ( std::function< void(std::optional< app_error >)>  callback)

Refresh a user's custom data. This will, in effect, refresh the user's auth session.

◆ refresh_token()

std::string realm::user::refresh_token ( ) const

The user's refresh token used to access the Realm Applcation.

This is required to make HTTP requests to the Realm App's REST API for functionality not exposed natively. It should be treated as sensitive data.

◆ state()

The current state of the user.


The documentation for this struct was generated from the following files: