Skip to content

Commit f859d37

Browse files
committed
fix: duplicate 2FA error messages (pterodactyl#2455)
1 parent c370e08 commit f859d37

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

resources/scripts/components/auth/LoginCheckpointContainer.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState } from 'react';
22
import { Link, RouteComponentProps } from 'react-router-dom';
33
import loginCheckpoint from '@/api/auth/loginCheckpoint';
4-
import { httpErrorToHuman } from '@/api/http';
54
import LoginFormContainer from '@/components/auth/LoginFormContainer';
65
import { ActionCreator } from 'easy-peasy';
76
import { StaticContext } from 'react-router';
@@ -20,8 +19,7 @@ interface Values {
2019
type OwnProps = RouteComponentProps<Record<string, string | undefined>, StaticContext, { token?: string }>
2120

2221
type Props = OwnProps & {
23-
addError: ActionCreator<FlashStore['addError']['payload']>;
24-
clearFlashes: ActionCreator<FlashStore['clearFlashes']['payload']>;
22+
clearAndAddHttpError: ActionCreator<FlashStore['clearAndAddHttpError']['payload']>;
2523
}
2624

2725
const LoginCheckpointContainer = () => {
@@ -79,9 +77,7 @@ const LoginCheckpointContainer = () => {
7977
};
8078

8179
const EnhancedForm = withFormik<Props, Values>({
82-
handleSubmit: ({ code, recoveryCode }, { setSubmitting, props: { addError, clearFlashes, location } }) => {
83-
clearFlashes();
84-
80+
handleSubmit: ({ code, recoveryCode }, { setSubmitting, props: { clearAndAddHttpError, location } }) => {
8581
loginCheckpoint(location.state?.token || '', code, recoveryCode)
8682
.then(response => {
8783
if (response.complete) {
@@ -95,7 +91,7 @@ const EnhancedForm = withFormik<Props, Values>({
9591
.catch(error => {
9692
console.error(error);
9793
setSubmitting(false);
98-
addError({ message: httpErrorToHuman(error) });
94+
clearAndAddHttpError({ error: error });
9995
});
10096
},
10197

@@ -106,7 +102,7 @@ const EnhancedForm = withFormik<Props, Values>({
106102
})(LoginCheckpointContainer);
107103

108104
export default ({ history, location, ...props }: OwnProps) => {
109-
const { addError, clearFlashes } = useFlash();
105+
const { clearAndAddHttpError } = useFlash();
110106

111107
if (!location.state?.token) {
112108
history.replace('/auth/login');
@@ -115,8 +111,7 @@ export default ({ history, location, ...props }: OwnProps) => {
115111
}
116112

117113
return <EnhancedForm
118-
addError={addError}
119-
clearFlashes={clearFlashes}
114+
clearAndAddHttpError={clearAndAddHttpError}
120115
history={history}
121116
location={location}
122117
{...props}

0 commit comments

Comments
 (0)