Skip to content

Commit 0a1ba43

Browse files
committed
makles changes to mfa docs
1 parent 840feb1 commit 0a1ba43

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

v2/mfa/email-sms-otp/otp-for-all-users.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ We can know which case it is by checking if the `emails` object returned from [M
388388
#### Case 1 implementation: User needs to enter their email
389389
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).
390390

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.
392392

393393
#### Case 2 implementation: User needs to complete the OTP challenge
394394

@@ -398,12 +398,16 @@ This case is when the user already has an email associated with their account an
398398

399399
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.
400400

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.
402402

403403
:::note
404404
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.
405405
:::
406406

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+
407411
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).
408412

409413
</CustomUIContent>

v2/mfa/email-sms-otp/otp-for-opt-in-users.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import FrontendMobileSubTabs from "/src/components/tabs/FrontendMobileSubTabs"
2222

2323
# OTP for specific users
2424

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+
2529
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:
2630
- Only users that have an `admin` role require to do OTP; OR
2731
- Only users that have enabled OTP on their account require to do OTP; OR

0 commit comments

Comments
 (0)