MultiFactorError interface

用户需要提供第二重身份验证才能成功登录时抛出的错误。

此错误的错误代码为 auth/multi-factor-auth-required

签名

export interface MultiFactorError extends AuthError 

扩展AuthError

属性

属性 类型 说明
customData AuthError['customData'] 和{ readonly actionType: (typeof OperationTypeMap)[keyof typeof OperationTypeMap];} 有关 MultiFactorError 的详细信息。

MultiFactorError.customData

有关 MultiFactorError 的详细信息。

签名

readonly customData: AuthError['customData'] & {
       
readonly operationType: (typeof OperationTypeMap)[keyof typeof OperationTypeMap];
   
};

示例

let resolver;
let multiFactorHints
;

signInWithEmailAndPassword
(auth, email, password)
   
.then((result) => {
     
// User signed in. No 2nd factor challenge is needed.
   
})
   
.catch((error) => {
     
if (error.code == 'auth/multi-factor-auth-required') {
        resolver
= getMultiFactorResolver(auth, error);
        multiFactorHints
= resolver.hints;
     
} else {
       
// Handle other errors.
     
}
   
});

// Obtain a multiFactorAssertion by verifying the second factor.

const userCredential = await resolver.resolveSignIn(multiFactorAssertion);