當使用者需要提供第二個因素才能成功登入時引發的錯誤。
此錯誤的錯誤代碼是auth/multi-factor-auth-required
。
簽名:
export interface MultiFactorError extends AuthError
擴充: AuthError
特性
財產 | 類型 | 描述 |
---|---|---|
自訂數據 | 驗證錯誤['customData'] & { 只讀操作類型: (操作類型對應類型)[ OperationTypeMap類型的鍵]; } | 有關 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);