Letting users add authenticators

Using the pre-built UI you can easily allow users to add an authentication method.

Adding backup authenticators

If a user is already enrolled with at least one authentication method, for security reasons they will have to complete a challenge before they can add a backup.

Track action

Passing redirectToSettings: true in the track request will redirect the user to a settings menu after they have completed a challenge.

const result = await authsignal.track({
  userId: user.id,
  action: "signIn",
  redirectUrl: "https://yourapp.com/callback",
  redirectToSettings: true,
});

const url = result.url;

From this menu they can add one or more backup authentication methods.

Retrieving a user’s enrollment status

The getUser method lets you determine if a user of your app is currently enrolled (i.e. they have added at least one authenticator).

curl https://api.authsignal.com/v1/users/usr_123 \
  -u YOUR_SECRET_KEY:

Programmatically adding authenticators

If you already have a user’s email or phone number in your own platform, you can enroll them with an Authsignal SMS or email authenticator programmatically.

You can do this by using the enrollVerifiedAuthenticator method:

curl https://api.authsignal.com/v1/users/usr_123/authenticators \
-u YOUR_SECRET_KEY: \
-H "Content-Type: application/json" \
-d '{"oobChannel": "SMS", "phoneNumber": "+64271234567"}'

This option should only be used if you have already verified the user’s email or phone number by sending them an email or SMS.

Next steps

Was this page helpful?