MultiFactorError interface

Lỗi được báo cáo khi người dùng cần cung cấp một yếu tố thứ hai để đăng nhập thành công.

Mã lỗi của lỗi này là auth/multi-factor-auth-required.

Chữ ký:

export interface MultiFactorError extends AuthError 

Mở rộng: AuthError

Thuộc tính

Tài sản Loại Mô tả
customData AuthError['customData'] và { chỉ đọc hoạt độngType: (typeof OperationTypeMap)[keyof typeof OperationTypeMap]; } Thông tin chi tiết về lỗi MultiFactorError.

MultiFactorError.customData

Thông tin chi tiết về lỗi MultiFactorError.

Chữ ký:

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

Ví dụ

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);