คลาสที่ใช้เพื่ออำนวยความสะดวกในการกู้คืนจาก MultiFactorError เมื่อผู้ใช้จำเป็นต้องระบุปัจจัยที่สองในการลงชื่อเข้าใช้
ลายเซ็น:
export interface MultiFactorResolver
คุณสมบัติ
คุณสมบัติ | พิมพ์ | คำอธิบาย |
---|---|---|
คำแนะนำ | ข้อมูลหลายปัจจัย [] | รายการคำแนะนำสำหรับปัจจัยที่สองที่จำเป็นในการลงชื่อเข้าใช้เซสชันปัจจุบันให้เสร็จสมบูรณ์ |
การประชุม | MultiFactorSession | ตัวระบุเซสชันสำหรับขั้นตอนการลงชื่อเข้าใช้ปัจจุบัน ซึ่งสามารถใช้เพื่อดำเนินการลงชื่อเข้าใช้ปัจจัยที่สองให้เสร็จสมบูรณ์ |
วิธีการ
วิธี | คำอธิบาย |
---|---|
solveSignIn(การยืนยัน) | ฟังก์ชันตัวช่วยเพื่อช่วยให้ผู้ใช้ลงชื่อเข้าใช้ด้วยปัจจัยที่สองโดยใช้ MultiFactorAssertion เพื่อยืนยันว่าผู้ใช้ทำภารกิจท้าทายปัจจัยที่สองได้สำเร็จ |
MultiFactorResolver.คำแนะนำ
รายการคำแนะนำสำหรับปัจจัยที่สองที่จำเป็นในการลงชื่อเข้าใช้เซสชันปัจจุบันให้เสร็จสมบูรณ์
ลายเซ็น:
readonly hints: MultiFactorInfo[];
MultiFactorResolver.เซสชัน
ตัวระบุเซสชันสำหรับขั้นตอนการลงชื่อเข้าใช้ปัจจุบัน ซึ่งสามารถใช้เพื่อดำเนินการลงชื่อเข้าใช้ปัจจัยที่สองให้เสร็จสมบูรณ์
ลายเซ็น:
readonly session: MultiFactorSession;
MultiFactorResolver.resolveSignIn()
ฟังก์ชันตัวช่วยเพื่อช่วยให้ผู้ใช้ลงชื่อเข้าใช้ด้วยปัจจัยที่สองโดยใช้ MultiFactorAssertion เพื่อยืนยันว่าผู้ใช้ทำภารกิจท้าทายปัจจัยที่สองได้สำเร็จ
ลายเซ็น:
resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredential>;
พารามิเตอร์
พารามิเตอร์ | พิมพ์ | คำอธิบาย |
---|---|---|
การยืนยัน | การยืนยันหลายปัจจัย | การยืนยันแบบหลายปัจจัยเพื่อแก้ไขปัญหาการลงชื่อเข้าใช้ |
ผลตอบแทน:
สัญญา < UserCredential >
คำสัญญาที่แก้ไขได้ด้วยวัตถุหนังสือรับรองผู้ใช้
ตัวอย่าง
const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
ตัวอย่าง
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);
// Show UI to let user select second factor.
multiFactorHints = resolver.hints;
} else {
// Handle other errors.
}
});
// The enrolled second factors that can be used to complete
// sign-in are returned in the `MultiFactorResolver.hints` list.
// UI needs to be presented to allow the user to select a second factor
// from that list.
const selectedHint = // ; selected from multiFactorHints
const phoneAuthProvider = new PhoneAuthProvider(auth);
const phoneInfoOptions = {
multiFactorHint: selectedHint,
session: resolver.session
};
const verificationId = phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
// Store `verificationId` and show UI to let user enter verification code.
// UI to enter verification code and continue.
// Continue button click handler
const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
const userCredential = await resolver.resolveSignIn(multiFactorAssertion);