You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: v2/mfa/email-sms-otp/otp-for-all-users.mdx
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -388,7 +388,7 @@ We can know which case it is by checking if the `emails` object returned from [M
388
388
#### Case 1 implementation: User needs to enter their email
389
389
In this case, we need to create a form wherein the user can enter their email. Once they submit the form, we need to call the [createCode API](/docs/passwordless/custom-ui/login-otp).
390
390
391
-
After this API call, you can show the user the enter OTP screen, and call the [consumeCode API](/docs/passwordless/custom-ui/login-otp#step-3-verifying-the-input-otp).
391
+
After this API call, you can show the user the enter OTP screen, and call the [consumeCode API](/docs/passwordless/custom-ui/login-otp#step-3-verifying-the-input-otp). If the API call returns a `RESTART_FLOW_ERROR`, you can handle this by asking the user to enter their email once again and then call the `createCode` function.
392
392
393
393
#### Case 2 implementation: User needs to complete the OTP challenge
394
394
@@ -398,12 +398,16 @@ This case is when the user already has an email associated with their account an
398
398
399
399
You can even show a UI here asking the user to pick an email from the array if you like. Either way, when you have an email, you can all the [createCode API](/docs/passwordless/custom-ui/login-otp) to send the code to that email.
400
400
401
-
After this API call, you can show the user the enter OTP screen, and call the [consumeCode API](/docs/passwordless/custom-ui/login-otp#step-3-verifying-the-input-otp).
401
+
After this API call, you can show the user the enter OTP screen, and call the [consumeCode API](/docs/passwordless/custom-ui/login-otp#step-3-verifying-the-input-otp). If the API call returns a `RESTART_FLOW_ERROR`, you can handle this by calling the `createCode` function once again in the background.
402
402
403
403
:::note
404
404
Notice that in Case 2, there is no UI for the user to enter an email. That happens silently. The user only sees the enter OTP screen.
405
405
:::
406
406
407
+
We recommend that you add a sign out button when showing the second factor (case 1 or case 2) so that users can use this to escape out of the flow in case they are unable to complete the second factor. When the sign out button is clicked, you want to:
408
+
- Call the `await clearLoginAttemptInfo()` function (if on web) to clear the state that's set in th browser storage when calling the `createCode` function.
409
+
- Call the sign out function / API to clear the tokens.
410
+
407
411
On successful verification of the code, the `otp-email` factor is marked as completed and the `v` value is updated in the session based on if there are any more factors that the user needs to complete. The next step would be to check this `v` value in the MFA claim and redirect the user to the application page, or get information about the next factor using the [MFA info endpoint](../frontend-setup#mfa-info-endpoint).
Copy file name to clipboardExpand all lines: v2/mfa/email-sms-otp/otp-for-opt-in-users.mdx
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -22,6 +22,10 @@ import FrontendMobileSubTabs from "/src/components/tabs/FrontendMobileSubTabs"
22
22
23
23
# OTP for specific users
24
24
25
+
:::important
26
+
Before reading the below, please first go through the setup for [OTP for all users](./otp-for-all-users) to understand the basics of how MFA with OTP works, and then come back here.
27
+
:::
28
+
25
29
In this page, we will show you how to implement an MFA policy that requires certain users to do the OTP challenge via email or sms. You can decide which those users are based on any criteria. For example:
26
30
- Only users that have an `admin` role require to do OTP; OR
27
31
- Only users that have enabled OTP on their account require to do OTP; OR
0 commit comments