From 693014c6e882115264e33f30987d5b134d740393 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Fri, 12 Jan 2024 22:15:07 +0200 Subject: [PATCH 1/2] fix(clerk-js): Hide backup codes when adding `phone_code` mfa and instance setting is off --- .../UserProfile/MfaPhoneCodeScreen.tsx | 65 ++++++++++--------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/packages/clerk-js/src/ui/components/UserProfile/MfaPhoneCodeScreen.tsx b/packages/clerk-js/src/ui/components/UserProfile/MfaPhoneCodeScreen.tsx index 2ec2f3505fa..edb267993c7 100644 --- a/packages/clerk-js/src/ui/components/UserProfile/MfaPhoneCodeScreen.tsx +++ b/packages/clerk-js/src/ui/components/UserProfile/MfaPhoneCodeScreen.tsx @@ -3,6 +3,7 @@ import type { PhoneNumberResource } from '@clerk/types'; import React from 'react'; import { useWizard, Wizard } from '../../common'; +import { useEnvironment } from '../../contexts'; import type { LocalizationKey } from '../../customizables'; import { Button, Col, Icon, localizationKeys, Text } from '../../customizables'; import type { FormProps } from '../../elements'; @@ -21,10 +22,12 @@ import { AddPhone, VerifyPhone } from './PhoneForm'; type MfaPhoneCodeScreenProps = FormProps; export const MfaPhoneCodeScreen = withCardStateProvider((props: MfaPhoneCodeScreenProps) => { - const { onReset } = props; + const { onReset, onSuccess } = props; const ref = React.useRef(); const wizard = useWizard({ defaultStep: 2 }); + const isInstanceWithBackupCodes = useEnvironment().userSettings.attributes.backup_code.enabled; + return ( wizard.goToStep(0)} onUnverifiedPhoneClick={phone => { @@ -51,15 +54,17 @@ export const MfaPhoneCodeScreen = withCardStateProvider((props: MfaPhoneCodeScre title={localizationKeys('userProfile.mfaPhoneCodePage.title')} resourceRef={ref} /> - } - /> + {isInstanceWithBackupCodes && ( + } + /> + )} ); }); @@ -113,26 +118,28 @@ const AddMfa = (props: AddMfaProps) => { )} colorScheme='neutral' /> - - {availableMethods.map(phone => { - const { country } = getCountryFromPhoneString(phone.phoneNumber); + {availableMethods.length > 0 && ( + + {availableMethods.map(phone => { + const { country } = getCountryFromPhoneString(phone.phoneNumber); - const formattedPhone = stringToFormattedPhoneString(phone.phoneNumber); + const formattedPhone = stringToFormattedPhoneString(phone.phoneNumber); - return ( - - ); - })} - + return ( + + ); + })} + + )} Date: Fri, 12 Jan 2024 22:15:33 +0200 Subject: [PATCH 2/2] fix(clerk-js): Hide backup codes when adding `phone_code` mfa and instance setting is off --- .changeset/curly-toes-complain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/curly-toes-complain.md diff --git a/.changeset/curly-toes-complain.md b/.changeset/curly-toes-complain.md new file mode 100644 index 00000000000..e588ae070bd --- /dev/null +++ b/.changeset/curly-toes-complain.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Hide backup codes when adding `phone_code` mfa and instance setting is off.