MultiFactorError interface

Lỗi xuất hiện khi người dùng cần cung cấp yếu tố thứ hai để đăng nhập thành công.

Mã lỗi cho lỗi này là auth/multi-factor-auth-required .

Chữ ký:

export interface MultiFactorError extends AuthError 

Mở rộng: AuthError

Của cải

Tài sản Kiểu Sự miêu tả
dữ liệu tùy chỉnh Lỗi xác thực ['customData'] & { readonly OperationType: (typeof OperationTypeMap )[keyof typeof OperationTypeMap ]; } Thông tin chi tiết về MultiFactorError.

MultiFactorError.customData

Thông tin chi tiết về 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);