From f5dfe86effa31791adb08f344feb02e2f669b263 Mon Sep 17 00:00:00 2001 From: Ward Pieters Date: Sun, 18 Oct 2020 00:42:52 +0200 Subject: [PATCH] fix: duplicate disable 2FA error messages --- .../components/dashboard/forms/DisableTwoFactorModal.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx b/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx index 170cd01d3..d4f986942 100644 --- a/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx +++ b/resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx @@ -7,7 +7,6 @@ import { object, string } from 'yup'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import disableAccountTwoFactor from '@/api/account/disableAccountTwoFactor'; -import { httpErrorToHuman } from '@/api/http'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; @@ -16,11 +15,10 @@ interface Values { } export default ({ ...props }: RequiredModalProps) => { - const { addError, clearFlashes } = useStoreActions((actions: Actions) => actions.flashes); + const { clearAndAddHttpError } = useStoreActions((actions: Actions) => actions.flashes); const updateUserData = useStoreActions((actions: Actions) => actions.user.updateUserData); const submit = ({ password }: Values, { setSubmitting }: FormikHelpers) => { - clearFlashes('account:two-factor'); disableAccountTwoFactor(password) .then(() => { updateUserData({ useTotp: false }); @@ -29,7 +27,7 @@ export default ({ ...props }: RequiredModalProps) => { .catch(error => { console.error(error); - addError({ message: httpErrorToHuman(error), key: 'account:two-factor' }); + clearAndAddHttpError({ error: error, key: 'account:two-factor' }); setSubmitting(false); }); };