Stay organized with collections
Save and categorize content based on your preferences.
Methods
enroll
- enroll
(
assertion
:
MultiFactorAssertion
,
displayName
?
:
string
|
null
)
:
Promise
<
void
>
-
Parameters
-
-
Optional displayName: string | null
Returns Promise<void>
unenroll
- unenroll
(
option
:
MultiFactorInfo
|
string
)
:
Promise
<
void
>
-
Parameters
Returns Promise<void>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.
[null,null,["Last updated 2022-07-27 UTC."],[],[],null,["- [firebase](/docs/reference/js/v8/firebase).\n- [User](/docs/reference/js/v8/firebase.User).\n- MultiFactorUser \nThis is the interface that defines the multi-factor related properties and\noperations pertaining to a [firebase.User](/docs/reference/js/v8/firebase.User).\n\nIndex\n\nProperties\n\n- [enrolledFactors](/docs/reference/js/v8/firebase.user.MultiFactorUser#enrolledfactors)\n\nMethods\n\n- [enroll](/docs/reference/js/v8/firebase.user.MultiFactorUser#enroll)\n- [getSession](/docs/reference/js/v8/firebase.user.MultiFactorUser#getsession)\n- [unenroll](/docs/reference/js/v8/firebase.user.MultiFactorUser#unenroll)\n\nProperties\n\nenrolledFactors \nenrolledFactors: [MultiFactorInfo](/docs/reference/js/v8/firebase.auth.MultiFactorInfo)\\[\\] \nReturns a list of the user's enrolled second factors.\n\nMethods\n\nenroll\n\n- enroll ( assertion : [MultiFactorAssertion](/docs/reference/js/v8/firebase.auth.MultiFactorAssertion) , displayName ? : string \\| null ) : Promise \\\u003c void \\\u003e\n- Enrolls a second factor as identified by the\n [firebase.auth.MultiFactorAssertion](/docs/reference/js/v8/firebase.auth.MultiFactorAssertion) for the current user.\n On resolution, the user tokens are updated to reflect the change in the\n JWT payload.\n Accepts an additional display name parameter used to identify the second\n factor to the end user.\n Recent re-authentication is required for this operation to succeed.\n On successful enrollment, existing Firebase sessions (refresh tokens) are\n revoked. When a new factor is enrolled, an email notification is sent\n to the user's email.\n\n Error Codes\n\n auth/invalid-verification-code\n : Thrown if the verification code is not valid.\n\n auth/missing-verification-code\n : Thrown if the verification code is missing.\n\n auth/invalid-verification-id\n : Thrown if the credential is a\n [firebase.auth.PhoneAuthProvider.credential](/docs/reference/js/v8/firebase.auth.PhoneAuthProvider#credential) and the verification\n ID of the credential is not valid.\n\n auth/missing-verification-id\n : Thrown if the verification ID is missing.\n\n auth/code-expired\n : Thrown if the verification code has expired.\n\n auth/maximum-second-factor-count-exceeded\n : Thrown if The maximum allowed number of second factors on a user\n has been exceeded.\n\n auth/second-factor-already-in-use\n : Thrown if the second factor is already enrolled on this account.\n\n auth/unsupported-first-factor\n : Thrown if the first factor being used to sign in is not supported.\n\n auth/unverified-email\n : Thrown if the email of the account is not verified.\n\n auth/requires-recent-login\n : Thrown if the user's last sign-in time does not meet the security\n threshold. Use [firebase.User.reauthenticateWithCredential](/docs/reference/js/v8/firebase.User#reauthenticatewithcredential) to\n resolve.\n\n example\n :\n\n firebase.auth().currentUser.multiFactor.getSession()\n .then(function(multiFactorSession) {\n // Send verification code\n var phoneAuthProvider = new firebase.auth.PhoneAuthProvider();\n var phoneInfoOptions = {\n phoneNumber: phoneNumber,\n session: multiFactorSession\n };\n return phoneAuthProvider.verifyPhoneNumber(\n phoneInfoOptions, appVerifier);\n }).then(function(verificationId) {\n // Store verificationID and show UI to let user enter verification code.\n });\n\n var phoneAuthCredential =\n firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode);\n var multiFactorAssertion =\n firebase.auth.PhoneMultiFactorGenerator.assertion(phoneAuthCredential);\n firebase.auth().currentUser.multiFactor.enroll(multiFactorAssertion)\n .then(function() {\n // Second factor enrolled.\n });\n\n\n Parameters\n -\n\n assertion: [MultiFactorAssertion](/docs/reference/js/v8/firebase.auth.MultiFactorAssertion) \n The multi-factor assertion to enroll with.\n -\n\n Optional displayName: string \\| null \n The display name of the second factor.\n\n Returns Promise\\\u003cvoid\\\u003e\n\ngetSession\n\n- getSession ( ) : Promise \\\u003c [MultiFactorSession](/docs/reference/js/v8/firebase.auth.MultiFactorSession) \\\u003e\n- Returns the session identifier for a second factor enrollment operation.\n This is used to identify the current user trying to enroll a second factor.\n\n Returns Promise\\\u003c[MultiFactorSession](/docs/reference/js/v8/firebase.auth.MultiFactorSession)\\\u003e\n\n The promise that resolves with the\n [firebase.auth.MultiFactorSession](/docs/reference/js/v8/firebase.auth.MultiFactorSession).\n\n Error Codes\n\n auth/user-token-expired\n : Thrown if the token of the user is expired.\n\nunenroll\n\n- unenroll ( option : [MultiFactorInfo](/docs/reference/js/v8/firebase.auth.MultiFactorInfo) \\| string ) : Promise \\\u003c void \\\u003e\n- Unenrolls the specified second factor. To specify the factor to remove, pass\n a [firebase.auth.MultiFactorInfo](/docs/reference/js/v8/firebase.auth.MultiFactorInfo) object\n (retrieved from `enrolledFactors()`)\n or the factor's UID string.\n Sessions are not revoked when the account is downgraded. An email\n notification is likely to be sent to the user notifying them of the change.\n Recent re-authentication is required for this operation to succeed.\n When an existing factor is unenrolled, an email notification is sent to the\n user's email.\n\n Error Codes\n\n auth/multi-factor-info-not-found\n : Thrown if the user does not have a second factor matching the\n identifier provided.\n\n auth/requires-recent-login\n : Thrown if the user's last sign-in time does not meet the security\n threshold. Use [firebase.User.reauthenticateWithCredential](/docs/reference/js/v8/firebase.User#reauthenticatewithcredential) to\n resolve.\n\n example\n :\n\n var options = firebase.auth().currentUser.multiFactor.enrolledFactors;\n // Present user the option to unenroll.\n return firebase.auth().currentUser.multiFactor.unenroll(options[i])\n .then(function() {\n // User successfully unenrolled selected factor.\n }).catch(function(error) {\n // Handler error.\n });\n\n\n Parameters\n -\n\n option: [MultiFactorInfo](/docs/reference/js/v8/firebase.auth.MultiFactorInfo) \\| string \n The multi-factor option to unenroll.\n\nReturns Promise\\\u003cvoid\\\u003e"]]
This is the interface that defines the multi-factor related properties and operations pertaining to a firebase.User.