Index
Properties
Methods
Properties
enrolledFactors
Returns a list of the user's enrolled second factors.
Methods
enroll
-
Enrolls a second factor as identified by the firebase.auth.MultiFactorAssertion for the current user. On resolution, the user tokens are updated to reflect the change in the JWT payload. Accepts an additional display name parameter used to identify the second factor to the end user. Recent re-authentication is required for this operation to succeed. On successful enrollment, existing Firebase sessions (refresh tokens) are revoked. When a new factor is enrolled, an email notification is sent to the user’s email.
Error Codes
- auth/invalid-verification-code
- Thrown if the verification code is not valid.
- auth/missing-verification-code
- Thrown if the verification code is missing.
- auth/invalid-verification-id
- Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
- auth/missing-verification-id
- Thrown if the verification ID is missing.
- auth/code-expired
- Thrown if the verification code has expired.
- auth/maximum-second-factor-count-exceeded
- Thrown if The maximum allowed number of second factors on a user has been exceeded.
- auth/second-factor-already-in-use
- Thrown if the second factor is already enrolled on this account.
- auth/unsupported-first-factor
- Thrown if the first factor being used to sign in is not supported.
- auth/unverified-email
- Thrown if the email of the account is not verified.
- auth/requires-recent-login
- Thrown if the user's last sign-in time does not meet the security threshold. Use firebase.User.reauthenticateWithCredential to resolve.
Parameters
-
assertion: MultiFactorAssertion
The multi-factor assertion to enroll with.
-
Optional displayName: string | null
The display name of the second factor.
Returns Promise<void>
getSession
-
Returns the session identifier for a second factor enrollment operation. This is used to identify the current user trying to enroll a second factor.
Returns Promise<MultiFactorSession>
The promise that resolves with the firebase.auth.MultiFactorSession.
Error Codes
- auth/user-token-expired
- Thrown if the token of the user is expired.
unenroll
-
Unenrolls the specified second factor. To specify the factor to remove, pass a firebase.auth.MultiFactorInfo object (retrieved from
enrolledFactors()
) or the factor's UID string. Sessions are not revoked when the account is downgraded. An email notification is likely to be sent to the user notifying them of the change. Recent re-authentication is required for this operation to succeed. When an existing factor is unenrolled, an email notification is sent to the user’s email.Error Codes
- auth/multi-factor-info-not-found
- Thrown if the user does not have a second factor matching the identifier provided.
- auth/requires-recent-login
- Thrown if the user's last sign-in time does not meet the security threshold. Use firebase.User.reauthenticateWithCredential to resolve.
Parameters
-
option: MultiFactorInfo | string
The multi-factor option to unenroll.
Returns Promise<void>
This is the interface that defines the multi-factor related properties and operations pertaining to a firebase.User.