firebase:: auth:: User
#include <user.h>
Firebase user account object.
Summary
This class allows you to manipulate the profile of a user, link to and unlink from authentication providers, and refresh authentication tokens.
Inheritance
Inherits from: firebase::auth::UserInfoInterface
Constructors and Destructors |
|
---|---|
User()
|
|
User(const User &)
Copy constructor.
|
|
~User()
|
Public functions |
|
---|---|
Delete()
|
Future< void >
Deletes the user account.
|
DeleteLastResult() const
|
Future< void >
Get results of the most recent call to Delete.
|
GetToken(bool force_refresh)
|
Future< std::string >
The Java Web Token (JWT) that can be used to identify the user to the backend.
|
GetTokenLastResult() const
|
Future< std::string >
Get results of the most recent call to GetToken.
|
LinkAndRetrieveDataWithCredential(const Credential & credential)
|
Deprecated. This is a deprecated method. Please use LinkWithCredential(const Credential&) instead. |
LinkAndRetrieveDataWithCredentialLastResult() const
|
Deprecated. |
LinkWithCredential(const Credential & credential)
|
Future< AuthResult >
Links the user with the given 3rd party credentials.
|
LinkWithCredentialLastResult() const
|
Future< AuthResult >
Get results of the most recent call to LinkWithCredential.
|
LinkWithCredentialLastResult_DEPRECATED() const
|
Deprecated. |
LinkWithCredential_DEPRECATED(const Credential & credential)
|
Deprecated. This is a deprecated method. Please use LinkWithCredential(const Credential&) instead. |
LinkWithProvider(FederatedAuthProvider *provider) const
|
Future< AuthResult >
|
LinkWithProvider_DEPRECATED(FederatedAuthProvider *provider) const
|
Deprecated. This is a deprecated method. Please use LinkWithProvider(FederatedAuthProvider*) instead. |
Reauthenticate(const Credential & credential)
|
Future< void >
Convenience function for ReauthenticateAndRetrieveData that discards the returned AdditionalUserInfo data.
|
ReauthenticateAndRetrieveData(const Credential & credential)
|
Future< AuthResult >
Reauthenticate using a credential.
|
ReauthenticateAndRetrieveDataLastResult() const
|
Future< AuthResult >
Get results of the most recent call to ReauthenticateAndRetrieveData.
|
ReauthenticateAndRetrieveDataLastResult_DEPRECATED() const
|
Deprecated. |
ReauthenticateAndRetrieveData_DEPRECATED(const Credential & credential)
|
Deprecated. This is a deprecated method. Please use ReauthenticateAndRetrieveData(const Credential&) instead. |
ReauthenticateLastResult() const
|
Future< void >
Get results of the most recent call to Reauthenticate.
|
ReauthenticateWithProvider(FederatedAuthProvider *provider) const
|
Future< AuthResult >
Re-authenticates the user with a federated auth provider.
|
ReauthenticateWithProvider_DEPRECATED(FederatedAuthProvider *provider) const
|
Deprecated.
This is a deprecated method. Please use ReauthenticateWithProvider(FederatedAuthProvider*) instead. Re-authenticates the user with a federated auth provider. |
Reload()
|
Future< void >
Refreshes the data for this user.
|
ReloadLastResult() const
|
Future< void >
Get results of the most recent call to Reload.
|
SendEmailVerification()
|
Future< void >
Initiates email verification for the user.
|
SendEmailVerificationBeforeUpdatingEmail(const char *email)
|
Future< void >
Send an email to verify the ownership of the account, then update to the new email.
|
SendEmailVerificationBeforeUpdatingEmailLastResult() const
|
Future< void >
Get results of the most recent call to SendEmailVerificationBeforeUpdatingEmail.
|
SendEmailVerificationLastResult() const
|
Future< void >
Get results of the most recent call to SendEmailVerification.
|
Unlink(const char *provider)
|
Future< AuthResult >
Unlinks the current user from the provider specified.
|
UnlinkLastResult() const
|
Future< AuthResult >
Get results of the most recent call to Unlink.
|
UnlinkLastResult_DEPRECATED() const
|
Deprecated. |
Unlink_DEPRECATED(const char *provider)
|
Deprecated. This is a deprecated method. Please use Unlink(const char*) instead. |
UpdateEmail(const char *email)
|
Future< void >
|
UpdateEmailLastResult() const
|
Future< void >
|
UpdatePassword(const char *password)
|
Future< void >
Attempts to change the password for the current user.
|
UpdatePasswordLastResult() const
|
Future< void >
Get results of the most recent call to UpdatePassword.
|
UpdatePhoneNumberCredential(const PhoneAuthCredential & credential)
|
Updates the currently linked phone number on the user.
|
UpdatePhoneNumberCredentialLastResult() const
|
Get results of the most recent call to UpdatePhoneNumberCredential.
|
UpdatePhoneNumberCredentialLastResult_DEPRECATED() const
|
Deprecated.
Get results of the most recent call to UpdatePhoneNumberCredential_DEPRECATED.
|
UpdatePhoneNumberCredential_DEPRECATED(const Credential & credential)
|
Deprecated. This is a deprecated method. Please use UpdatePhoneNumberCredential(const PhoneAuthCredential&) instead. |
UpdateUserProfile(const UserProfile & profile)
|
Future< void >
Updates a subset of user profile information.
|
UpdateUserProfileLastResult() const
|
Future< void >
Get results of the most recent call to UpdateUserProfile.
|
display_name() const
|
virtual std::string
Gets the display name associated with the user, if any.
|
email() const
|
virtual std::string
Gets email associated with the user, if any.
|
is_anonymous() const
|
bool
Returns true if user signed in anonymously.
|
is_email_verified() const
|
bool
Returns true if the email address associated with this user has been verified.
|
is_valid() const
|
bool
Returns whether this User object represents a valid user.
|
metadata() const
|
Gets the metadata for this user account.
|
operator!=(const User &) const
|
bool
Inequality operator.
|
operator=(const User &)
|
User &
Assignment operator.
|
operator==(const User &) const
|
bool
Equality operator.
|
phone_number() const
|
virtual std::string
Gets the phone number for the user, in E.164 format.
|
photo_url() const
|
virtual std::string
Gets the photo url associated with the user, if any.
|
provider_data() const
|
std::vector< UserInfoInterface >
Gets the third party profile data associated with this user returned by the authentication server, if any.
|
provider_data_DEPRECATED() const
|
const std::vector< UserInfoInterface * > &
|
provider_id() const
|
virtual std::string
Gets the provider ID for the user (For example, "Facebook").
|
uid() const
|
virtual std::string
Gets the unique Firebase user ID for the user.
|
Structs |
|
---|---|
firebase:: |
Parameters to the UpdateUserProfile() function. |
Public functions
DeleteLastResult
Future< void > DeleteLastResult() const
Get results of the most recent call to Delete.
GetToken
Future< std::string > GetToken( bool force_refresh )
The Java Web Token (JWT) that can be used to identify the user to the backend.
If a current ID token is still believed to be valid (i.e. it has not yet expired), that token will be returned immediately. A developer may set the optional force_refresh flag to get a new ID token, whether or not the existing token has expired. For example, a developer may use this when they have discovered that the token is invalid for some other reason.
GetTokenLastResult
Future< std::string > GetTokenLastResult() const
Get results of the most recent call to GetToken.
LinkAndRetrieveDataWithCredential
Future< SignInResult > LinkAndRetrieveDataWithCredential( const Credential & credential )
Deprecated. This is a deprecated method. Please use LinkWithCredential(const Credential&) instead.
Links the user with the given 3rd party credentials.
For example, a Facebook login access token, a Twitter token/token-secret pair. Status will be an error if the token is invalid, expired, or otherwise not accepted by the server as well as if the given 3rd party user id is already linked with another user account or if the current user is already linked with another id from the same provider.
Data from the Identity Provider used to sign-in is returned in the AdditionalUserInfo inside SignInResult.
LinkAndRetrieveDataWithCredentialLastResult
Future< SignInResult > LinkAndRetrieveDataWithCredentialLastResult() const
Get results of the most recent call to LinkAndRetrieveDataWithCredential.
LinkWithCredential
Future< AuthResult > LinkWithCredential( const Credential & credential )
Links the user with the given 3rd party credentials.
For example, a Facebook login access token, a Twitter token/token-secret pair.
Status will be an error if the token is invalid, expired, or otherwise not accepted by the server as well as if the given 3rd party user id is already linked with another user account or if the current user is already linked with another id from the same provider.
Data from the Identity Provider used to sign-in is returned in the AdditionalUserInfo inside AuthResult.
LinkWithCredentialLastResult
Future< AuthResult > LinkWithCredentialLastResult() const
Get results of the most recent call to LinkWithCredential.
LinkWithCredentialLastResult_DEPRECATED
Future< User * > LinkWithCredentialLastResult_DEPRECATED() const
Get results of the most recent call to LinkWithCredential_DEPRECATED.
LinkWithCredential_DEPRECATED
Future< User * > LinkWithCredential_DEPRECATED( const Credential & credential )
Deprecated. This is a deprecated method. Please use LinkWithCredential(const Credential&) instead.
Convenience function for ReauthenticateAndRetrieveData that discards the returned AdditionalUserInfo in SignInResult.
LinkWithProvider
Future< AuthResult > LinkWithProvider( FederatedAuthProvider *provider ) const
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Future
|
LinkWithProvider_DEPRECATED
Future< SignInResult > LinkWithProvider_DEPRECATED( FederatedAuthProvider *provider ) const
Deprecated. This is a deprecated method. Please use LinkWithProvider(FederatedAuthProvider*) instead.
Links this user with a federated auth provider.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Future
|
Reauthenticate
Future< void > Reauthenticate( const Credential & credential )
Convenience function for ReauthenticateAndRetrieveData that discards the returned AdditionalUserInfo data.
ReauthenticateAndRetrieveData
Future< AuthResult > ReauthenticateAndRetrieveData( const Credential & credential )
Reauthenticate using a credential.
Some APIs (for example, UpdatePassword, Delete) require that the token used to invoke them be from a recent login attempt. This API takes an existing credential for the user and retrieves fresh tokens, ensuring that the operation can proceed. Developers can call this method prior to calling UpdatePassword() to ensure success.
Data from the Identity Provider used to sign-in is returned in the AdditionalUserInfo inside the returned AuthResult.
Returns an error if the existing credential is not for this user or if sign-in with that credential failed.
ReauthenticateAndRetrieveDataLastResult
Future< AuthResult > ReauthenticateAndRetrieveDataLastResult() const
Get results of the most recent call to ReauthenticateAndRetrieveData.
ReauthenticateAndRetrieveDataLastResult_DEPRECATED
Future< SignInResult > ReauthenticateAndRetrieveDataLastResult_DEPRECATED() const
Get results of the most recent call to ReauthenticateAndRetrieveData_DEPRECATED.
ReauthenticateAndRetrieveData_DEPRECATED
Future< SignInResult > ReauthenticateAndRetrieveData_DEPRECATED( const Credential & credential )
Deprecated. This is a deprecated method. Please use ReauthenticateAndRetrieveData(const Credential&) instead.
Reauthenticate using a credential.
Data from the Identity Provider used to sign-in is returned in the AdditionalUserInfo inside the returned SignInResult.
Returns an error if the existing credential is not for this user or if sign-in with that credential failed.
ReauthenticateLastResult
Future< void > ReauthenticateLastResult() const
Get results of the most recent call to Reauthenticate.
ReauthenticateWithProvider
Future< AuthResult > ReauthenticateWithProvider( FederatedAuthProvider *provider ) const
Re-authenticates the user with a federated auth provider.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Future
|
ReauthenticateWithProvider_DEPRECATED
Future< SignInResult > ReauthenticateWithProvider_DEPRECATED( FederatedAuthProvider *provider ) const
Re-authenticates the user with a federated auth provider.
Deprecated. This is a deprecated method. Please use ReauthenticateWithProvider(FederatedAuthProvider*) instead.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
A Future
|
Reload
Future< void > Reload()
Refreshes the data for this user.
For example, the attached providers, email address, display name, etc.
ReloadLastResult
Future< void > ReloadLastResult() const
Get results of the most recent call to Reload.
SendEmailVerification
Future< void > SendEmailVerification()
Initiates email verification for the user.
SendEmailVerificationBeforeUpdatingEmail
Future< void > SendEmailVerificationBeforeUpdatingEmail( const char *email )
Send an email to verify the ownership of the account, then update to the new email.
SendEmailVerificationBeforeUpdatingEmailLastResult
Future< void > SendEmailVerificationBeforeUpdatingEmailLastResult() const
Get results of the most recent call to SendEmailVerificationBeforeUpdatingEmail.
SendEmailVerificationLastResult
Future< void > SendEmailVerificationLastResult() const
Get results of the most recent call to SendEmailVerification.
Unlink
Future< AuthResult > Unlink( const char *provider )
Unlinks the current user from the provider specified.
Status will be an error if the user is not linked to the given provider.
UnlinkLastResult
Future< AuthResult > UnlinkLastResult() const
Get results of the most recent call to Unlink.
UnlinkLastResult_DEPRECATED
Future< User * > UnlinkLastResult_DEPRECATED() const
Get results of the most recent call to Unlink_DEPRECATED.
Unlink_DEPRECATED
Future< User * > Unlink_DEPRECATED( const char *provider )
Deprecated. This is a deprecated method. Please use Unlink(const char*) instead.
Unlinks the current user from the provider specified. Status will be an error if the user is not linked to the given provider.
UpdateEmail
Future< void > UpdateEmail( const char *email )
Deprecated. This is a deprecated method. Please use SendEmailVerificationBeforeUpdatingEmail(email) instead.
Sets the email address for the user.
May fail if there is already an email/password-based account for the same email address.
UpdateEmailLastResult
Future< void > UpdateEmailLastResult() const
Get results of the most recent call to UpdateEmail.
UpdatePassword
Future< void > UpdatePassword( const char *password )
Attempts to change the password for the current user.
For an account linked to an Identity Provider (IDP) with no password, this will result in the account becoming an email/password-based account while maintaining the IDP link. May fail if the password is invalid, if there is a conflicting email/password-based account, or if the token has expired. To retrieve fresh tokens, call Reauthenticate.
UpdatePasswordLastResult
Future< void > UpdatePasswordLastResult() const
Get results of the most recent call to UpdatePassword.
UpdatePhoneNumberCredential
Future< User > UpdatePhoneNumberCredential( const PhoneAuthCredential & credential )
Updates the currently linked phone number on the user.
This is useful when a user wants to change their phone number. It is a shortcut to calling Unlink(phone_credential.provider().c_str()) and then LinkWithCredential(phone_credential). credential
must have been created with PhoneAuthProvider.
UpdatePhoneNumberCredentialLastResult
Future< User > UpdatePhoneNumberCredentialLastResult() const
Get results of the most recent call to UpdatePhoneNumberCredential.
UpdatePhoneNumberCredentialLastResult_DEPRECATED
Future< User * > UpdatePhoneNumberCredentialLastResult_DEPRECATED() const
Get results of the most recent call to UpdatePhoneNumberCredential_DEPRECATED.
UpdatePhoneNumberCredential_DEPRECATED
Future< User * > UpdatePhoneNumberCredential_DEPRECATED( const Credential & credential )
Deprecated. This is a deprecated method. Please use UpdatePhoneNumberCredential(const PhoneAuthCredential&) instead.
Updates the currently linked phone number on the user. This is useful when a user wants to change their phone number. It is a shortcut to calling Unlink_DEPRECATED(phone_credential.provider().c_str()) and then LinkWithCredential_DEPRECATED(phone_credential). credential
must have been created with PhoneAuthProvider.
UpdateUserProfile
Future< void > UpdateUserProfile( const UserProfile & profile )
Updates a subset of user profile information.
UpdateUserProfileLastResult
Future< void > UpdateUserProfileLastResult() const
Get results of the most recent call to UpdateUserProfile.
User
User()
display_name
virtual std::string display_name() const
Gets the display name associated with the user, if any.
virtual std::string email() const
Gets email associated with the user, if any.
is_anonymous
bool is_anonymous() const
Returns true if user signed in anonymously.
is_email_verified
bool is_email_verified() const
Returns true if the email address associated with this user has been verified.
is_valid
bool is_valid() const
Returns whether this User object represents a valid user.
Could be false on Users contained with AuthResult structures from failed Auth operations.
phone_number
virtual std::string phone_number() const
Gets the phone number for the user, in E.164 format.
photo_url
virtual std::string photo_url() const
Gets the photo url associated with the user, if any.
provider_data
std::vector< UserInfoInterface > provider_data() const
Gets the third party profile data associated with this user returned by the authentication server, if any.
provider_data_DEPRECATED
const std::vector< UserInfoInterface * > & provider_data_DEPRECATED() const
Deprecated. This is a deprecated method. Please use provider_data() instead.
Gets the third party profile data associated with this user returned by the authentication server, if any.
provider_id
virtual std::string provider_id() const
Gets the provider ID for the user (For example, "Facebook").
uid
virtual std::string uid() const
Gets the unique Firebase user ID for the user.
~User
~User()