Skip to content

Commit f5dfe86

Browse files
committed
fix: duplicate disable 2FA error messages
1 parent f859d37 commit f5dfe86

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

resources/scripts/components/dashboard/forms/DisableTwoFactorModal.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { object, string } from 'yup';
77
import { Actions, useStoreActions } from 'easy-peasy';
88
import { ApplicationStore } from '@/state';
99
import disableAccountTwoFactor from '@/api/account/disableAccountTwoFactor';
10-
import { httpErrorToHuman } from '@/api/http';
1110
import tw from 'twin.macro';
1211
import Button from '@/components/elements/Button';
1312

@@ -16,11 +15,10 @@ interface Values {
1615
}
1716

1817
export default ({ ...props }: RequiredModalProps) => {
19-
const { addError, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
18+
const { clearAndAddHttpError } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
2019
const updateUserData = useStoreActions((actions: Actions<ApplicationStore>) => actions.user.updateUserData);
2120

2221
const submit = ({ password }: Values, { setSubmitting }: FormikHelpers<Values>) => {
23-
clearFlashes('account:two-factor');
2422
disableAccountTwoFactor(password)
2523
.then(() => {
2624
updateUserData({ useTotp: false });
@@ -29,7 +27,7 @@ export default ({ ...props }: RequiredModalProps) => {
2927
.catch(error => {
3028
console.error(error);
3129

32-
addError({ message: httpErrorToHuman(error), key: 'account:two-factor' });
30+
clearAndAddHttpError({ error: error, key: 'account:two-factor' });
3331
setSubmitting(false);
3432
});
3533
};

0 commit comments

Comments
 (0)