Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Error message appear on original tab when navigate from Magic code expired page #34703

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading