From f859d37b251d4434c26f52700ca1420d91dd5788 Mon Sep 17 00:00:00 2001 From: Ward Pieters Date: Sun, 18 Oct 2020 00:02:46 +0200 Subject: [PATCH] fix: duplicate 2FA error messages (https://github.com/pterodactyl/panel/issues/2455) --- .../components/auth/LoginCheckpointContainer.tsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/resources/scripts/components/auth/LoginCheckpointContainer.tsx b/resources/scripts/components/auth/LoginCheckpointContainer.tsx index f4507328..4c3dff59 100644 --- a/resources/scripts/components/auth/LoginCheckpointContainer.tsx +++ b/resources/scripts/components/auth/LoginCheckpointContainer.tsx @@ -1,7 +1,6 @@ import React, { useState } from 'react'; import { Link, RouteComponentProps } from 'react-router-dom'; import loginCheckpoint from '@/api/auth/loginCheckpoint'; -import { httpErrorToHuman } from '@/api/http'; import LoginFormContainer from '@/components/auth/LoginFormContainer'; import { ActionCreator } from 'easy-peasy'; import { StaticContext } from 'react-router'; @@ -20,8 +19,7 @@ interface Values { type OwnProps = RouteComponentProps, StaticContext, { token?: string }> type Props = OwnProps & { - addError: ActionCreator; - clearFlashes: ActionCreator; + clearAndAddHttpError: ActionCreator; } const LoginCheckpointContainer = () => { @@ -79,9 +77,7 @@ const LoginCheckpointContainer = () => { }; const EnhancedForm = withFormik({ - handleSubmit: ({ code, recoveryCode }, { setSubmitting, props: { addError, clearFlashes, location } }) => { - clearFlashes(); - + handleSubmit: ({ code, recoveryCode }, { setSubmitting, props: { clearAndAddHttpError, location } }) => { loginCheckpoint(location.state?.token || '', code, recoveryCode) .then(response => { if (response.complete) { @@ -95,7 +91,7 @@ const EnhancedForm = withFormik({ .catch(error => { console.error(error); setSubmitting(false); - addError({ message: httpErrorToHuman(error) }); + clearAndAddHttpError({ error: error }); }); }, @@ -106,7 +102,7 @@ const EnhancedForm = withFormik({ })(LoginCheckpointContainer); export default ({ history, location, ...props }: OwnProps) => { - const { addError, clearFlashes } = useFlash(); + const { clearAndAddHttpError } = useFlash(); if (!location.state?.token) { history.replace('/auth/login'); @@ -115,8 +111,7 @@ export default ({ history, location, ...props }: OwnProps) => { } return