The class used to facilitate recovery from firebase.auth.MultiFactorError when a user needs to provide a second factor to sign in.

example
firebase.auth().signInWithEmailAndPassword() .then(function(result) { // User signed in. No 2nd factor challenge is needed. }) .catch(function(error) { if (error.code == 'auth/multi-factor-auth-required') { var resolver = error.resolver; // Show UI to let user select second factor.var multiFactorHints = resolver.hints; } else { // Handle other errors. } }); // The enrolled second factors that can be used to complete// sign-in are returned in the `MultiFactorResolver.hints` list.// UI needs to be presented to allow the user to select a second factor// from that list.var selectedHint = // ; selected from multiFactorHintsvar phoneAuthProvider = new firebase.auth.PhoneAuthProvider(); var phoneInfoOptions = { multiFactorHint: selectedHint, session: resolver.session }; phoneAuthProvider.verifyPhoneNumber( phoneInfoOptions, appVerifier ).then(function(verificationId) { // store verificationID and show UI to let user enter verification code. }); // UI to enter verification code and continue.// Continue button click handlervar phoneAuthCredential = firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode); var multiFactorAssertion = firebase.auth.PhoneMultiFactorGenerator.assertion(phoneAuthCredential); resolver.resolveSignIn(multiFactorAssertion) .then(function(userCredential) { // User signed in. });

Index

Constructors

Properties

Methods

Constructors

Private constructor

Properties

auth

auth:Auth

The Auth instance used to sign in with the first factor.

hints

The list of hints for the second factors needed to complete the sign-in for the current session.

session

The session identifier for the current sign-in flow, which can be used to complete the second factor sign-in.

Methods

resolveSignIn

  • resolveSignIn ( assertion MultiFactorAssertion ): Promise< UserCredential >
  • A helper function to help users complete sign in with a second factor using an firebase.auth.MultiFactorAssertion confirming the user successfully completed the second factor challenge.

    Error Codes

    auth/invalid-verification-code
    Thrown if the verification code is not valid.
    auth/missing-verification-code
    Thrown if the verification code is missing.
    auth/invalid-verification-id
    Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
    auth/missing-verification-id
    Thrown if the verification ID is missing.
    auth/code-expired
    Thrown if the verification code has expired.
    auth/invalid-multi-factor-session
    Thrown if the request does not contain a valid proof of first factor successful sign-in.
    auth/missing-multi-factor-session
    Thrown if The request is missing proof of first factor successful sign-in.

    Parameters

    Returns Promise<UserCredential>

    The promise that resolves with the user credential object.