사용자 와 관련된 다단계 관련 속성 및 작업을 정의하는 인터페이스 .
서명:
export interface MultiFactorUser
속성
재산 | 유형 | 설명 |
---|---|---|
등록된 요소 | 다중 요소 정보 [] | 사용자가 등록한 두 번째 요소 목록을 반환합니다. |
행동 양식
방법 | 설명 |
---|---|
등록(어설션, 표시 이름) | 사용자에 대한 MultiFactorAssertion 으로 식별된 두 번째 요소를 등록합니다. |
getSession() | 두 번째 요소 등록 작업에 대한 세션 식별자를 반환합니다. 이는 두 번째 요소를 등록하려는 사용자를 식별하는 데 사용됩니다. |
탈퇴(선택) | 지정된 두 번째 요소를 등록 취소합니다. |
MultiFactorUser.enrolledFactors
사용자가 등록한 두 번째 요소 목록을 반환합니다.
서명:
readonly enrolledFactors: MultiFactorInfo[];
MultiFactorUser.enroll()
사용자에 대한 MultiFactorAssertion 으로 식별된 두 번째 요소를 등록합니다.
해결 시 JWT 페이로드의 변경 사항을 반영하도록 사용자 토큰이 업데이트됩니다. 최종 사용자에게 두 번째 요소를 식별하는 데 사용되는 추가 표시 이름 매개 변수를 허용합니다. 이 작업이 성공하려면 최근 재인증이 필요합니다. 등록이 완료되면 기존 Firebase 세션(새로 고침 토큰)이 취소됩니다. 새로운 요소가 등록되면 사용자의 이메일로 이메일 알림이 전송됩니다.
서명:
enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise<void>;
매개변수
매개변수 | 유형 | 설명 |
---|---|---|
역설 | MultiFactorAssertion | 등록할 다중 요소 어설션입니다. |
이름 표시하기 | 문자열 | 없는 | 두 번째 요소의 표시 이름입니다. |
보고:
약속<공허>
예
const multiFactorUser = multiFactor(auth.currentUser);
const multiFactorSession = await multiFactorUser.getSession();
// Send verification code.
const phoneAuthProvider = new PhoneAuthProvider(auth);
const phoneInfoOptions = {
phoneNumber: phoneNumber,
session: multiFactorSession
};
const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
// Obtain verification code from user.
const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
await multiFactorUser.enroll(multiFactorAssertion);
// Second factor enrolled.
MultiFactorUser.getSession()
두 번째 요소 등록 작업에 대한 세션 식별자를 반환합니다. 이는 두 번째 요소를 등록하려는 사용자를 식별하는 데 사용됩니다.
서명:
getSession(): Promise<MultiFactorSession>;
보고:
약속< MultiFactorSession >
MultiFactorSession 으로 해결되는 약속 .
예
const multiFactorUser = multiFactor(auth.currentUser);
const multiFactorSession = await multiFactorUser.getSession();
// Send verification code.
const phoneAuthProvider = new PhoneAuthProvider(auth);
const phoneInfoOptions = {
phoneNumber: phoneNumber,
session: multiFactorSession
};
const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
// Obtain verification code from user.
const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
await multiFactorUser.enroll(multiFactorAssertion);
MultiFactorUser.unenroll()
지정된 두 번째 요소를 등록 취소합니다.
제거할 요소를 지정하려면 MultiFactorInfo 개체( MultiFactorUser.enrolledFactors 에서 검색됨)를 전달합니다. ) 또는 요소의 UID 문자열입니다. 계정이 등록 해제되어도 세션은 취소되지 않습니다. 변경 사항을 알리는 이메일 알림이 사용자에게 전송될 수 있습니다. 이 작업이 성공하려면 최근 재인증이 필요합니다. 기존 요소가 등록 취소되면 이메일 알림이 사용자의 이메일로 전송됩니다.
서명:
unenroll(option: MultiFactorInfo | string): Promise<void>;
매개변수
매개변수 | 유형 | 설명 |
---|---|---|
옵션 | 다중 요소 정보 | 끈 | 등록을 취소하는 다단계 옵션입니다. |
보고:
약속<공허>
- 등록 취소 작업이 완료되면 해결되는
Promise
입니다.
예
const multiFactorUser = multiFactor(auth.currentUser);
// Present user the option to choose which factor to unenroll.
await multiFactorUser.unenroll(multiFactorUser.enrolledFactors[i])