Realm C++ SDK Version v2.2.0
|
#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 | |
user & | operator= (const user &)=default |
user & | operator= (user &&)=default |
user (std::shared_ptr< app::User > 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::document > | get_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< app::User > | m_user |
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.
|
strong |
The state of the user object.
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.
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.
name | The name of the Atlas App Services function to be called. |
arguments | The string represented extended json to be provided to the function. |
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.
name | The name of the Atlas App Services function to be called. |
arguments | The string represented extended json to be provided to the function. |
callback | The completion handler to call when the function call is complete. This handler is executed on the thread the method was called from. |
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.
name | The name of the Atlas App Services function to be called. |
arguments | The BSON array to be provided to the function. |
callback | The completion handler to call when the function call is complete. This handler is executed on the thread the method was called from. |
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.
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.
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.
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.
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.
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.
enum user::state realm::user::state | ( | ) | const |
The current state of the user.