User

class User : NSObject, UserInfo

Represents a user. Firebase Auth does not attempt to validate users when loading them from the keychain. Invalidated users (such as those whose passwords have been changed on another client) are automatically logged out when an auth-dependent operation is attempted or when the ID token is automatically refreshed. This class is thread-safe.

  • Indicates the user represents an anonymous user.

    Declaration

    Swift

    var isAnonymous: Bool { get }
  • Indicates the email address associated with this user has been verified.

    Declaration

    Swift

    var isEmailVerified: Bool { get }
  • A refresh token; useful for obtaining new access tokens independently. This property should only be used for advanced scenarios, and is not typically needed.

    Declaration

    Swift

    var refreshToken: String? { get }
  • Profile data for each identity provider, if any. This data is cached on sign-in and updated when linking or unlinking.

    Declaration

    Swift

    var providerData: [UserInfo] { get }
  • Metadata associated with the Firebase user in question.

    Declaration

    Swift

    var metadata: FIRUserMetadata { get }
  • This class should not be instantiated. To retrieve the current user, use FIRAuth.currentUser. To sign a user in or out, use the methods on FIRAuth.

  • Updates the email address for the user. On success, the cached user profile data is updated. May fail if there is already an account with this email address that was created using email and password authentication.

    Possible error codes:

    + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
        sent in the request.
    + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
        the console for this action.
    + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
        sending update email.
    + `FIRAuthErrorCodeEmailAlreadyInUse` - Indicates the email is already in use by another
        account.
    + `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
    + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a users email is a security
        sensitive operation that requires a recent login from the user. This error indicates
        the user has not signed in recently enough. To resolve, reauthenticate the user by
        invoking reauthenticateWithCredential:completion: on FIRUser.
    

    See FIRAuthErrors for a list of error codes that are common to all FIRUser methods.

    Declaration

    Swift

    func updateEmail(to email: String, completion: UserProfileChangeCallback? = nil)

    Parameters

    email

    The email address for the user.

    completion

    Optionally; the block invoked when the user profile change has finished. Invoked asynchronously on the main thread in the future.

  • Updates the password for the user. On success, the cached user profile data is updated.

    Possible error codes:

    + `FIRAuthErrorCodeOperationNotAllowed` - Indicates the administrator disabled
        sign in with the specified identity provider.
    + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a users password is a security
        sensitive operation that requires a recent login from the user. This error indicates
        the user has not signed in recently enough. To resolve, reauthenticate the user by
        invoking reauthenticateWithCredential:completion: on FIRUser.
    + `FIRAuthErrorCodeWeakPassword` - Indicates an attempt to set a password that is
        considered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo
        dictionary object will contain more detailed explanation that can be shown to the user.
    

    See FIRAuthErrors for a list of error codes that are common to all FIRUser methods.

    Declaration

    Swift

    func updatePassword(to password: String, completion: UserProfileChangeCallback? = nil)

    Parameters

    password

    The new password for the user.

    completion

    Optionally; the block invoked when the user profile change has finished. Invoked asynchronously on the main thread in the future.

  • Updates the phone number for the user. On success, the cached user profile data is updated.

    Possible error codes:

    + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a users phone number is a security
        sensitive operation that requires a recent login from the user. This error indicates
        the user has not signed in recently enough. To resolve, reauthenticate the user by
        invoking reauthenticateWithCredential:completion: on FIRUser.
    

    See FIRAuthErrors for a list of error codes that are common to all FIRUser methods.

    Declaration

    Swift

    func updatePhoneNumber(_ phoneNumberCredential: FIRPhoneAuthCredential, completion: UserProfileChangeCallback? = nil)

    Parameters

    phoneNumberCredential

    The new phone number credential corresponding to the phone number to be added to the Firebase account, if a phone number is already linked to the account this new phone number will replace it.

    completion

    Optionally; the block invoked when the user profile change has finished. Invoked asynchronously on the main thread in the future.

  • Creates an object which may be used to change the user’s profile data.

    Set the properties of the returned object, then call FIRUserProfileChangeRequest.commitChangesWithCallback: to perform the updates atomically.

    Declaration

    Swift

    func createProfileChangeRequest() -> UserProfileChangeRequest