Realm C++ SDK main@ea665a54a297dd13d7a3789dd5f5ea7317032c84
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
 
std::optional< bsoncxx::documentget_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 call_function (const std::string &name, const std::vector< bsoncxx > &args_bson, std::function< void(std::optional< bsoncxx >, std::optional< app_error >)> callback) const
 
std::future< std::optional< bsoncxx > > call_function (const std::string &name, const std::vector< bsoncxx > &args_bson) 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/4]

std::future< std::optional< std::string > > realm::user::call_function ( const std::string &  name,
const std::string &  args_ejson 
) 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.
Returns
A future containing an optional std::string once the operation has completed. This handler is executed on the thread the method was called from.

◆ call_function() [2/4]

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.

◆ call_function() [3/4]

std::future< std::optional< bsoncxx > > realm::user::call_function ( const std::string &  name,
const std::vector< bsoncxx > &  args_bson 
) 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 BSON array to be provided to the function.
Returns
A future containing optional BSON once the operation has completed.

◆ call_function() [4/4]

void realm::user::call_function ( const std::string &  name,
const std::vector< bsoncxx > &  args_bson,
std::function< void(std::optional< bsoncxx >, 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 BSON array 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.

◆ get_custom_data()

std::optional< bsoncxx::document > realm::user::get_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: