Kesalahan terjadi ketika pengguna perlu memberikan faktor kedua agar berhasil masuk.
Kode kesalahan untuk kesalahan ini adalah auth/multi-factor-auth-required
.
Tanda tangan:
export interface MultiFactorError extends AuthError
Perluasan: AuthError
Properti
Properti | Jenis | Keterangan |
---|---|---|
Data khusus | Kesalahan Otentikasi ['customData'] & { tipe operasi hanya baca: (typeof OperationTypeMap )[kunci dari tipe OperationTypeMap ]; } | Detail tentang MultiFactorError. |
MultiFactorError.customData
Detail tentang MultiFactorError.
Tanda tangan:
readonly customData: AuthError['customData'] & {
readonly operationType: (typeof OperationTypeMap)[keyof typeof OperationTypeMap];
};
Contoh
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);