Skip to content

Commit

Permalink
Merge pull request #34703 from tienifr/fix/33637
Browse files Browse the repository at this point in the history
fix: Error message appear on original tab when navigate from Magic code expired page
  • Loading branch information
yuwenmemon authored Jan 22, 2024
2 parents 0ebc6e4 + e81dafd commit 0d8dc40
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function BaseValidateCodeForm(props) {
const [twoFactorAuthCode, setTwoFactorAuthCode] = useState('');
const [timeRemaining, setTimeRemaining] = useState(30);
const [recoveryCode, setRecoveryCode] = useState('');
const [needToClearError, setNeedToClearError] = useState(props.account.errors);

const prevRequiresTwoFactorAuth = usePrevious(props.account.requiresTwoFactorAuth);
const prevValidateCode = usePrevious(props.credentials.validateCode);
Expand All @@ -98,7 +99,7 @@ function BaseValidateCodeForm(props) {
const input2FARef = useRef();
const timerRef = useRef();

const hasError = Boolean(props.account) && !_.isEmpty(props.account.errors);
const hasError = Boolean(props.account) && !_.isEmpty(props.account.errors) && !needToClearError;
const isLoadingResendValidationForm = props.account.loadingForm === CONST.FORMS.RESEND_VALIDATE_CODE_FORM;
const shouldDisableResendValidateCode = props.network.isOffline || props.account.isLoading;
const isValidateCodeFormSubmitting =
Expand Down Expand Up @@ -212,6 +213,18 @@ function BaseValidateCodeForm(props) {
Session.clearSignInData();
};

useEffect(() => {
if (!needToClearError) {
return;
}

if (props.account.errors) {
Session.clearAccountMessages();
return;
}
setNeedToClearError(false);
}, [props.account.errors, needToClearError]);

/**
* Switches between 2fa and recovery code, clears inputs and errors
*/
Expand Down

0 comments on commit 0d8dc40

Please sign in to comment.