forked from Alex/Pterodactyl-Panel
fix: duplicate disable 2FA error messages
This commit is contained in:
parent
f859d37b25
commit
f5dfe86eff
@ -7,7 +7,6 @@ import { object, string } from 'yup';
|
|||||||
import { Actions, useStoreActions } from 'easy-peasy';
|
import { Actions, useStoreActions } from 'easy-peasy';
|
||||||
import { ApplicationStore } from '@/state';
|
import { ApplicationStore } from '@/state';
|
||||||
import disableAccountTwoFactor from '@/api/account/disableAccountTwoFactor';
|
import disableAccountTwoFactor from '@/api/account/disableAccountTwoFactor';
|
||||||
import { httpErrorToHuman } from '@/api/http';
|
|
||||||
import tw from 'twin.macro';
|
import tw from 'twin.macro';
|
||||||
import Button from '@/components/elements/Button';
|
import Button from '@/components/elements/Button';
|
||||||
|
|
||||||
@ -16,11 +15,10 @@ interface Values {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default ({ ...props }: RequiredModalProps) => {
|
export default ({ ...props }: RequiredModalProps) => {
|
||||||
const { addError, clearFlashes } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
|
const { clearAndAddHttpError } = useStoreActions((actions: Actions<ApplicationStore>) => actions.flashes);
|
||||||
const updateUserData = useStoreActions((actions: Actions<ApplicationStore>) => actions.user.updateUserData);
|
const updateUserData = useStoreActions((actions: Actions<ApplicationStore>) => actions.user.updateUserData);
|
||||||
|
|
||||||
const submit = ({ password }: Values, { setSubmitting }: FormikHelpers<Values>) => {
|
const submit = ({ password }: Values, { setSubmitting }: FormikHelpers<Values>) => {
|
||||||
clearFlashes('account:two-factor');
|
|
||||||
disableAccountTwoFactor(password)
|
disableAccountTwoFactor(password)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateUserData({ useTotp: false });
|
updateUserData({ useTotp: false });
|
||||||
@ -29,7 +27,7 @@ export default ({ ...props }: RequiredModalProps) => {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
addError({ message: httpErrorToHuman(error), key: 'account:two-factor' });
|
clearAndAddHttpError({ error: error, key: 'account:two-factor' });
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user