From 9a7a04ecb43d1e8150c2cc9d60dc21d597024a8e Mon Sep 17 00:00:00 2001 From: Mihaly Lengyel Date: Mon, 11 Dec 2023 23:11:09 +0100 Subject: [PATCH] fix: self-review fixes --- lib/build/passwordless-shared4.js | 10 ++-------- .../passwordless/components/features/mfa/index.tsx | 11 ++--------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/lib/build/passwordless-shared4.js b/lib/build/passwordless-shared4.js index 404521faa..eed661f07 100644 --- a/lib/build/passwordless-shared4.js +++ b/lib/build/passwordless-shared4.js @@ -16,7 +16,6 @@ var button = require("./emailpassword-shared2.js"); var windowHandler = require("supertokens-web-js/utils/windowHandler"); var recipe$1 = require("./multifactorauth-shared.js"); var validators$1 = require("./passwordless-shared3.js"); -var recipe$2 = require("./passwordless-shared2.js"); var SuperTokensBranding = require("./SuperTokensBranding.js"); var generalError = require("./emailpassword-shared.js"); var sessionprebuiltui = require("./sessionprebuiltui.js"); @@ -26,6 +25,7 @@ var validators = require("./emailpassword-shared6.js"); var arrowLeftIcon = require("./arrowLeftIcon.js"); var multifactorauth = require("./multifactorauth-shared2.js"); var backButton = require("./emailpassword-shared8.js"); +var recipe$2 = require("./passwordless-shared2.js"); function _interopDefault(e) { return e && e.__esModule ? e : { default: e }; @@ -3851,7 +3851,6 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { }, [dispatch] ); - var dynamicLoginMethods = uiEntry.useDynamicLoginMethods(); var onLoad = React__namespace.useCallback( function (mfaInfo) { return genericComponentOverrideContext.__awaiter(_this, void 0, void 0, function () { @@ -3861,7 +3860,6 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { loginAttemptInfo, isAlreadySetup, isAllowedToSetup, - enabledContactMethods, createCodeInfo, factorId, createResp; @@ -3890,11 +3888,7 @@ function useOnLoad(props, recipeImplementation, dispatch, userContext) { props.contactMethod === "EMAIL" ? mfaInfo.factors.isAllowedToSetup.includes("otp-email") : mfaInfo.factors.isAllowedToSetup.includes("otp-phone"); - enabledContactMethods = recipe$2.getEnabledContactMethods( - props.recipe.config.contactMethod, - dynamicLoginMethods - ); - if (!(loginAttemptInfo && !enabledContactMethods.includes(loginAttemptInfo.contactMethod))) + if (!(loginAttemptInfo && props.contactMethod !== loginAttemptInfo.contactMethod)) return [3 /*break*/, 3]; return [ 4 /*yield*/, diff --git a/lib/ts/recipe/passwordless/components/features/mfa/index.tsx b/lib/ts/recipe/passwordless/components/features/mfa/index.tsx index aa45b4f25..208779d17 100644 --- a/lib/ts/recipe/passwordless/components/features/mfa/index.tsx +++ b/lib/ts/recipe/passwordless/components/features/mfa/index.tsx @@ -34,10 +34,8 @@ import { useRethrowInRender, } from "../../../../../utils"; import MultiFactorAuth from "../../../../multifactorauth/recipe"; -import { useDynamicLoginMethods } from "../../../../multitenancy/dynamicLoginMethodsContext"; import SessionRecipe from "../../../../session/recipe"; import { getPhoneNumberUtils } from "../../../phoneNumberUtils"; -import { getEnabledContactMethods } from "../../../utils"; import MFAThemeWrapper from "../../themes/mfa"; import { defaultTranslationsPasswordless } from "../../themes/translations"; @@ -317,7 +315,7 @@ function useOnLoad( () => dispatch({ type: "setError", error: "SOMETHING_WENT_WRONG_ERROR" }), [dispatch] ); - const dynamicLoginMethods = useDynamicLoginMethods(); + const onLoad = React.useCallback( async (mfaInfo: { factors: MFAFactorInfo; email?: string; phoneNumber?: string }) => { let error: string | undefined = undefined; @@ -341,12 +339,7 @@ function useOnLoad( ? mfaInfo.factors.isAllowedToSetup.includes("otp-email") : mfaInfo.factors.isAllowedToSetup.includes("otp-phone"); - const enabledContactMethods = getEnabledContactMethods( - props.recipe.config.contactMethod, - dynamicLoginMethods - ); - - if (loginAttemptInfo && !enabledContactMethods.includes(loginAttemptInfo.contactMethod)) { + if (loginAttemptInfo && props.contactMethod !== loginAttemptInfo.contactMethod) { await recipeImplementation?.clearLoginAttemptInfo({ userContext }); loginAttemptInfo = undefined; }