Gate Users Until They Verify Their Phone
On this page
FusionAuth 1.59.0 and later can gate a user's account until the user verifies a phone number. A gated user can start the login process. The user can't finish login until the user proves ownership of the phone number from registration.
To turn on phone verification gating:
- Configure a messengerA configuration that FusionAuth uses to send messages, such as SMS, through a provider..
- Select the messenger in the Tenant.
- Turn on phone verification gating in the Tenant.
- When you want to change the verification message, customize the phone verification template.
- Turn on self-service registrationA feature that lets users create their own accounts. in the Application.
- Add a redirect URLThe URL where the authorization server sends the browser after login, with an authorization code or an error. to the Application.
- Test the gate.
Prerequisites#
This feature requires at least a Starter plan.
You need the following:
- FusionAuth
1.59.0or later. To install FusionAuth, see Install. To update an instance, see Update FusionAuth. - A paid plan and a license. To buy a plan, see Pricing. To activate an instance, see Licensing.
- A Twilio account. This guide uses a Twilio Messenger. To use another SMS provider, create a Generic Messenger instead.
Gating, Verification, and Pre-Verification#
Phone verification is available on every plan. Gating requires a paid plan.
Phone verification updates verified and verifiedReason on the user's phone number identity. Your application code can check these fields and block an unverified user.
With gating, FusionAuth blocks the unverified user instead. The hosted login pagesThe login, registration, password recovery, and multi-factor authentication pages that FusionAuth serves. A Theme controls the look of the pages. stop the user after login, and FusionAuth issues no JWT until the user verifies the phone number. Gating applies after FusionAuth creates the user.
Pre-verification requires users to verify a phone number before FusionAuth creates the user.
Configure the Messenger#
This guide uses the Admin UI. You can also configure everything with the API or with KickstartA file of API requests that FusionAuth runs on first startup to configure a new instance..
Log in to the Admin UI. Navigate to Settings -> Messengers , click Add Twilio messenger , and enter your Twilio account details. For more information, see Twilio Messenger.
Select the Messenger in the Tenant#
Navigate to Tenants -> Your Tenant and select the Identities tab. In the Messenger settings section, select the messenger you created.

Turn On Phone Verification Gating#
On the same Identities tab, configure the phone settings:
- Turn on Verify identity.
- Set Verification template. The default
Phone Verificationtemplate works for this guide. - Set Verification strategy.
ClickableLinksends an SMS message with a link that verifies the phone number.FormFieldsends a code that the user enters in FusionAuth. This guide uses the default,FormField. - Set Unverified behavior to
Gated.
The phone settings look like the following:

Save the Tenant.
Customize the Phone Verification Template#
When you want to change the verification message, navigate to Customizations -> Message Templates . Click on the Phone Verification template.
Change the text template, then save the template. You can also localize the message. For more information, see Message Templates.

Configure the Application#
Navigate to Applications and click on your Application.
On the Registration tab, go to the Self service registration section. Turn on self-service registration, and set Login type to Phone. Choose the fields that the registration form displays and requires.
Self-service registration is the simplest way to create a user with an unverified phone number. Other ways of creating users also work with the gate.

On the OAuth tab, turn on the Authorization Code grant. Add a URL to Authorized redirect URLs. Any valid URL works for this guide. In production, the code at the redirect URL must exchange the authorization code for a token.
Save the Application. FusionAuth returns to the list of Applications.
Click on your Application to see the Application details.

Copy the Registration URL and the OAuth IdP login URL. The Registration URL looks like https://local.fusionauth.io/oauth2/register?client_id=85a03867-dccf-4882-adde-1a79aeec50df&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Foauth-redirect.
Test the Gate#
Register in a different browser or a private window, so your Admin UI session doesn't interfere with the registration:
-
Open the Registration URL. Fill out the form with a valid phone number. After registration, FusionAuth sends a message that asks you to verify the phone number. The browser shows the phone verification gate page:

-
Open a different browser, not a new window of the same browser. Open the OAuth IdP login URL, and log in with the phone number and password of the new user. FusionAuth shows the same phone verification gate page.
-
In the Admin UI, open the new user. A question mark next to the phone number shows that the phone number isn't verified.

-
On the gate page, enter the code from the message. FusionAuth finishes the login and redirects to the redirect URL.
FusionAuth issues no JWT until the user verifies the phone number, whichever API or hosted login page the user logs in with. Until then, the user sees the gate page at every login. When your application logs users in with the Login API, the response status code shows that the user hasn't verified the phone number.
To make the gate page match your application, customize your theme. For more information, see Themes.
The User Object#
FusionAuth updates the phone number identity of the User during verification.
When phone verification is off at user creation, verified is false and verifiedReason is Disabled:
{
"active": true,
"birthDate": "1981-06-04",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"Company": "PiedPiper",
"PreviousCompany": "Aviato",
"user_type": "iconclast"
},
"phoneNumber": "+13035551212",
"encryptionScheme": "salted-pbkdf2-hmac-sha256",
"firstName": "Erlich",
"id": "00000000-0000-0000-0000-000000000001",
"identities": [
{
"primary": true,
"type": "phoneNumber",
"value": "+13035551212",
"verified": false,
"verifiedReason": "Disabled"
}
],
"insertInstant": 1630520102103,
"lastLoginInstant": 1630639038934,
"lastName": "Bachman",
"lastUpdateInstant": 1630602397679,
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1630520102697,
"tenantId": "30663132-6464-6665-3032-326466613934",
"twoFactor": {},
"usernameStatus": "ACTIVE",
"verified": false
}When phone verification is on at user creation, verified is false and verifiedReason is Pending:
{
"active": true,
"birthDate": "1981-06-04",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"Company": "PiedPiper",
"PreviousCompany": "Aviato",
"user_type": "iconclast"
},
"phoneNumber": "+13035551212",
"encryptionScheme": "salted-pbkdf2-hmac-sha256",
"firstName": "Erlich",
"id": "00000000-0000-0000-0000-000000000001",
"identities": [
{
"primary": true,
"type": "phoneNumber",
"value": "+13035551212",
"verified": false,
"verifiedReason": "Pending"
}
],
"insertInstant": 1630520102103,
"lastLoginInstant": 1630639038934,
"lastName": "Bachman",
"lastUpdateInstant": 1630602397679,
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1630520102697,
"tenantId": "30663132-6464-6665-3032-326466613934",
"twoFactor": {},
"usernameStatus": "ACTIVE",
"verified": false
}After the user verifies the phone number, verified is true and verifiedReason is Completed.
The Import Users API keeps the imported verification values, whatever the verification and gate settings.
Common Questions#
Do Existing Users Get Messages When I Enable a Gate?#
No. Enabling a gate sends no messages. Instead, an existing user with an unverified identity must verify the identity at their next login. An identity is unverified when the identity has verified: false and verifiedReason: "Pending". During login, the user clicks a link, and FusionAuth then sends the verification message.
When you use Elasticsearch for search, you can find the users that a gate will affect. Navigate to Users and search for verified: false. The search matches users with an unverified email address and users with an unverified registration.
User search doesn't index the verification status of phone numbers. You can't search for users with an unverified phone number.
How Do I Mark an Imported User as Verified?#
To verify the email address or phone number of one user in the Admin UI:
- Navigate to Users and open the details page of the user.
- Click the down arrow next to Edit user , then select Verify identity .
- Select the identity and click Confirm .
The Admin UI can't mark a registration as verified. To verify a registration, or to verify many users at once, use the API:
- Get a verification Id from the Resend Verification API for an email address, or from the Resend Registration Verification API for a registration. Set
sendVerifyEmailorsendVerifyRegistrationEmailtofalse, so FusionAuth returns the Id without sending an email. - Send the verification Id to the Verify Email API or the Verify Registration API.
To skip this step in future imports, set users[x].verified and users[x].registrations[x].verified in the Import Users API.
What Happens When I Enable Both Email and Registration Verification?#
Email verification confirms that the user owns an email address, once per Tenant. Registration verification confirms that the user opted in to one Application. For example, nine Applications in a Tenant might require only email verification, while a tenth Application also requires registration verification.
When a new user signs up for the tenth Application, FusionAuth sends one email: the registration verification email. Completing registration verification also verifies the email address. When an existing user registers for the tenth Application, FusionAuth sends a registration verification email, even if the user already verified their email address.
When you turn off Allow implicit verification in the Tenant, registration verification doesn't verify the email address. Users then verify the registration and the email address separately. The setting is on the Identities tab of the Tenant. See Identity Verification Settings.
Troubleshooting Phone Verification#
Verification Links and Codes Don't Work#
When a link or code from the verification message has expired, check the external identifier durations. Navigate to Tenants -> Your Tenant -> Advanced . In the External identifier durations section, change Phone verification. FusionAuth sets a default duration.
