From a67a480c72e4180410c016a02272b8d555731d3c Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Sat, 24 Aug 2024 01:21:29 +0200 Subject: [PATCH 1/3] update how we redirect to factors to match v0.46 in auth-react --- v2/mfa/step-up-auth.mdx | 14 +++++++++----- v2/mfa/totp/totp-for-opt-in-users.mdx | 8 ++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/v2/mfa/step-up-auth.mdx b/v2/mfa/step-up-auth.mdx index bc97c4f68..cb34597ee 100644 --- a/v2/mfa/step-up-auth.mdx +++ b/v2/mfa/step-up-auth.mdx @@ -542,19 +542,23 @@ To redirect the user to as factor challenge page and then navigate them back to import MultiFactorAuth from 'supertokens-auth-react/recipe/multifactorauth'; async function redirectToTotpSetupScreen() { - MultiFactorAuth.redirectToFactor(MultiFactorAuth.FactorIds.TOTP, false, true) + MultiFactorAuth.redirectToFactor({ + factorId: "totp", + stepUp: true, + redirectBack: true, + }) } ``` -- In the snippet above, we redirect to the [TOTP factor setup screen](https://master--6571be2867f75556541fde98.chromatic.com/?path=/story/totp-mfa--device-setup). The second argument represents a boolean for `forceSetup` which we set to false since we do not want to ask the user to create a new device. The third arg is also `true` since we want to redirect back to the current page after the user has finished setting up the device. -- You can also just redirect the user to `/{websiteBasePath}/mfa/totp?redirectToPath={currentPath}` if you don't want to use the above function. +- In the snippet above, we redirect to the [TOTP factor setup screen](https://master--6571be2867f75556541fde98.chromatic.com/?path=/story/totp-mfa--device-setup). We set the `stepUp` argument to `true` otherwise the MFA screen would detect that the user has already completed basic MFA requirements and would not show the verification screen. The `redirectBack` argument is set to `true` since we want to redirect back to the current page after the user has finished setting up the device. +- You can also just redirect the user to `/{websiteBasePath}/mfa/totp?setup=true&redirectToPath={currentPath}` if you don't want to use the above function. -In order to add a new device, you can redirect the user to `/{websiteBasePath}/mfa/totp?redirectToPath={currentPath}` from your settings page. This will show the [TOTP factor setup screen](https://master--6571be2867f75556541fde98.chromatic.com/?path=/story/totp-mfa--device-setup) to the user. The `redirectToPath` query param will also tell our SDK to redirect the user back to the current page after they have finished creating the device. +In order to add a new device, you can redirect the user to `/{websiteBasePath}/mfa/totp?setup=true&redirectToPath={currentPath}` from your settings page. This will show the [TOTP factor setup screen](https://master--6571be2867f75556541fde98.chromatic.com/?path=/story/totp-mfa--device-setup) to the user. The `redirectToPath` query param will also tell our SDK to redirect the user back to the current page after they have finished creating the device. @@ -613,7 +617,7 @@ function InvalidClaimHandler(props: React.PropsWithChildren) { let totpCompletedTime = claimValue.value?.c[MultiFactorAuth.FactorIds.TOTP] if (totpCompletedTime === undefined || totpCompletedTime < (DateProviderReference.getReferenceOrThrow().dateProvider.now() - 1000 * 60 * 5)) { - return
You need to complete TOTP before seeing this page. Please click here to finish to proceed.
+ return
You need to complete TOTP before seeing this page. Please click here to finish to proceed.
} // the user has finished TOTP, so we can render the children diff --git a/v2/mfa/totp/totp-for-opt-in-users.mdx b/v2/mfa/totp/totp-for-opt-in-users.mdx index 426509d90..80c7db6b0 100644 --- a/v2/mfa/totp/totp-for-opt-in-users.mdx +++ b/v2/mfa/totp/totp-for-opt-in-users.mdx @@ -548,11 +548,15 @@ In order to add a new device, you can call the following function from the front import MultiFactorAuth from 'supertokens-auth-react/recipe/multifactorauth'; async function redirectToTotpSetupScreen() { - MultiFactorAuth.redirectToFactor("totp", true, true) + MultiFactorAuth.redirectToFactor({ + factorId: "totp", + forceSetup: true, + redirectBack: true, + }) } ``` -- In the snippet above, we redirect to the [TOTP factor setup screen](https://6571be2867f75556541fde98-xieqfaxuuo.chromatic.com/?path=/story/totp-mfa--device-setup-with-single-next-option). The second argument represents a boolean for `forceSetup` which we set to true since we want the user to setup a new TOTP device. The third arg is also `true` since we want to redirect back to the current page after the user has finished setting up the device. +- In the snippet above, we redirect to the [TOTP factor setup screen](https://6571be2867f75556541fde98-xieqfaxuuo.chromatic.com/?path=/story/totp-mfa--device-setup-with-single-next-option). We set the `forceSetup` to `true` since we want the user to setup a new TOTP device. The `redirectBack` boolean is also `true` since we want to redirect back to the current page after the user has finished setting up the device. - You can also just redirect the user to `/{websiteBasePath}/mfa/totp?setup=true&redirectToPath={currentPath}` if you don't want to use the above function. From 8805908d2e5437b563f024b7b7cdbca7cb14bd26 Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Thu, 29 Aug 2024 14:03:19 +0200 Subject: [PATCH 2/3] feat: update lib versions in jsenv --- v2/src/plugins/codeTypeChecking/jsEnv/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v2/src/plugins/codeTypeChecking/jsEnv/package.json b/v2/src/plugins/codeTypeChecking/jsEnv/package.json index f1fa9be0b..b6cbbef47 100644 --- a/v2/src/plugins/codeTypeChecking/jsEnv/package.json +++ b/v2/src/plugins/codeTypeChecking/jsEnv/package.json @@ -56,13 +56,13 @@ "react-router-dom5": "npm:react-router-dom@^5.3.0", "socket.io": "^4.6.1", "socketio": "^1.0.0", - "supertokens-auth-react": "^0.44.0", - "supertokens-auth-react-script": "github:supertokens/supertokens-auth-react#0.44", + "supertokens-auth-react": "^0.46.0", + "supertokens-auth-react-script": "github:supertokens/supertokens-auth-react#0.46", "supertokens-node": "^20.0.0", "supertokens-node7": "npm:supertokens-node@7.3", "supertokens-react-native": "^5.0.0", - "supertokens-web-js": "^0.12.0", - "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.12", + "supertokens-web-js": "github:supertokens/supertokens-web-js#0.13", + "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.13", "supertokens-website": "^20.0.1", "supertokens-website-script": "github:supertokens/supertokens-website#20.0", "typescript": "^4.9.5", From 71317cc6fd18c7fb952b2bb15865d395ea9802ce Mon Sep 17 00:00:00 2001 From: Rishabh Poddar Date: Sat, 31 Aug 2024 11:00:09 +0530 Subject: [PATCH 3/3] Update v2/src/plugins/codeTypeChecking/jsEnv/package.json --- v2/src/plugins/codeTypeChecking/jsEnv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/src/plugins/codeTypeChecking/jsEnv/package.json b/v2/src/plugins/codeTypeChecking/jsEnv/package.json index b6cbbef47..2c0ce4097 100644 --- a/v2/src/plugins/codeTypeChecking/jsEnv/package.json +++ b/v2/src/plugins/codeTypeChecking/jsEnv/package.json @@ -61,7 +61,7 @@ "supertokens-node": "^20.0.0", "supertokens-node7": "npm:supertokens-node@7.3", "supertokens-react-native": "^5.0.0", - "supertokens-web-js": "github:supertokens/supertokens-web-js#0.13", + "supertokens-web-js": "^0.13.0", "supertokens-web-js-script": "github:supertokens/supertokens-web-js#0.13", "supertokens-website": "^20.0.1", "supertokens-website-script": "github:supertokens/supertokens-website#20.0",