From b0f22380625c45ed09f3af2b35e12d6ae1358df1 Mon Sep 17 00:00:00 2001 From: schmanu Date: Mon, 9 Oct 2023 12:11:42 +0200 Subject: [PATCH] fix: simplify MFA setup --- .../SignerAccountMFA/PasswordForm.tsx | 32 ++++--------------- .../settings/SignerAccountMFA/helper.ts | 28 +--------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/src/components/settings/SignerAccountMFA/PasswordForm.tsx b/src/components/settings/SignerAccountMFA/PasswordForm.tsx index 0f4d905974..f40e2e0522 100644 --- a/src/components/settings/SignerAccountMFA/PasswordForm.tsx +++ b/src/components/settings/SignerAccountMFA/PasswordForm.tsx @@ -1,40 +1,33 @@ -import { DeviceShareRecovery } from '@/hooks/wallets/mpc/recovery/DeviceShareRecovery' import { SecurityQuestionRecovery } from '@/hooks/wallets/mpc/recovery/SecurityQuestionRecovery' -import { Typography, TextField, FormControlLabel, Checkbox, Button, Box } from '@mui/material' +import { Typography, TextField, Button, Box } from '@mui/material' import { type Web3AuthMPCCoreKit } from '@web3auth/mpc-core-kit' import { useState, useMemo } from 'react' -import { Controller, useForm } from 'react-hook-form' +import { useForm } from 'react-hook-form' import { enableMFA } from './helper' enum PasswordFieldNames { oldPassword = 'oldPassword', newPassword = 'newPassword', confirmPassword = 'confirmPassword', - storeDeviceShare = 'storeDeviceShare', } type PasswordFormData = { [PasswordFieldNames.oldPassword]: string | undefined [PasswordFieldNames.newPassword]: string [PasswordFieldNames.confirmPassword]: string - [PasswordFieldNames.storeDeviceShare]: boolean } export const PasswordForm = ({ mpcCoreKit }: { mpcCoreKit: Web3AuthMPCCoreKit }) => { const formMethods = useForm({ mode: 'all', - defaultValues: async () => { - const isDeviceShareStored = await new DeviceShareRecovery(mpcCoreKit).isEnabled() - return { - [PasswordFieldNames.confirmPassword]: '', - [PasswordFieldNames.oldPassword]: undefined, - [PasswordFieldNames.newPassword]: '', - [PasswordFieldNames.storeDeviceShare]: isDeviceShareStored, - } + defaultValues: { + [PasswordFieldNames.confirmPassword]: '', + [PasswordFieldNames.oldPassword]: undefined, + [PasswordFieldNames.newPassword]: '', }, }) - const { register, formState, getValues, control, handleSubmit } = formMethods + const { register, formState, getValues, handleSubmit } = formMethods const [enablingMFA, setEnablingMFA] = useState(false) @@ -100,17 +93,6 @@ export const PasswordForm = ({ mpcCoreKit }: { mpcCoreKit: Web3AuthMPCCoreKit }) })} /> - ( - } - label="Do not ask for second factor on this device" - /> - )} - /> -