MultiFactor

public abstract class MultiFactor


Defines multi-factor related properties and operations pertaining to a FirebaseUser. This class acts as the main entry point for enrolling or un-enrolling second factors for a user, and provides access to their currently enrolled factors.

Summary

Public constructors

Public methods

abstract @NonNull Task<Void>
enroll(
    @NonNull MultiFactorAssertion multiFactorAssertion,
    @Nullable String displayName
)

Enrolls a second factor as identified by the MultiFactorAssertion parameter for the current user.

abstract @NonNull List<MultiFactorInfo>

Returns a list of the MultiFactorInfo already associated with this user.

abstract @NonNull Task<MultiFactorSession>

Returns a session identifier for a second factor enrollment operation.

abstract @NonNull Task<Void>
unenroll(@NonNull String factorUid)

Unenrolls a second factor from this user.

abstract @NonNull Task<Void>
unenroll(@NonNull MultiFactorInfo multiFactorInfo)

Unenrolls a second factor from this user.

Public constructors

MultiFactor

public MultiFactor()

Public methods

enroll

public abstract @NonNull Task<Voidenroll(
    @NonNull MultiFactorAssertion multiFactorAssertion,
    @Nullable String displayName
)

Enrolls a second factor as identified by the MultiFactorAssertion parameter for the current user.

On successful enrollment, existing Firebase sessions are revoked, and an email notification is sent to the user’s email. The user's must have a verified email to enroll a second factor.

A MultiFactorAssertion can be generated using getAssertion for enrolling phone number as a second factor or getAssertionForEnrollment for enrolling TOTP as a second factor.

Parameters
@NonNull MultiFactorAssertion multiFactorAssertion

the assertion representing the second factor to enroll

@Nullable String displayName

an optional name for identifying this second factor

getEnrolledFactors

public abstract @NonNull List<MultiFactorInfogetEnrolledFactors()

Returns a list of the MultiFactorInfo already associated with this user.

If the user does not have any enrolled factors, the list will be empty.

getSession

public abstract @NonNull Task<MultiFactorSessiongetSession()

Returns a session identifier for a second factor enrollment operation. This is used to identify the current user trying to enroll a second factor.

To be used when building a PhoneAuthOptions instance to call verifyPhoneNumber for phone factor enrollment, or when generating a TotpSecret instance for TOTP factor enrollment.

unenroll

public abstract @NonNull Task<Voidunenroll(@NonNull String factorUid)

Unenrolls a second factor from this user.

The factorUid to be passed in can be retrieved from getEnrolledFactors.

unenroll

public abstract @NonNull Task<Voidunenroll(@NonNull MultiFactorInfo multiFactorInfo)

Unenrolls a second factor from this user.

The MultiFactorInfo to be passed in can be gotten from getEnrolledFactors.