From 10cc79057e96642100da449e44f5215d33cb4476 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 18 Jul 2023 00:05:36 +0700 Subject: [PATCH 1/3] fix: preserve magic code when login --- src/libs/actions/Session/index.js | 2 +- .../signin/ValidateCodeForm/BaseValidateCodeForm.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index dc8cb5f63316..16f8e3f36403 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -172,7 +172,7 @@ function resendValidateCode(login = credentials.login) { key: ONYXKEYS.ACCOUNT, value: { errors: null, - loadingForm: CONST.FORMS.VALIDATE_CODE_FORM, + loadingForm: CONST.FORMS.RESEND_VALIDATION_FORM, }, }, ]; diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js index 4b640506ed89..09efa7dc2de8 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js @@ -89,7 +89,7 @@ function BaseValidateCodeForm(props) { const timerRef = useRef(); const hasError = Boolean(props.account) && !_.isEmpty(props.account.errors); - const isLoadingValidateCodeForm = props.account.loadingForm === (props.account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM); + const isLoadingResendCodeForm = props.account.loadingForm === CONST.FORMS.RESEND_VALIDATION_FORM; useEffect(() => { if (!(inputValidateCodeRef.current && hasError && (props.session.autoAuthState === CONST.AUTO_AUTH_STATE.FAILED || props.account.isLoading))) { @@ -202,11 +202,11 @@ function BaseValidateCodeForm(props) { }; useEffect(() => { - if (!isLoadingValidateCodeForm) { + if (!isLoadingResendCodeForm) { return; } clearLocalSignInData(); - }, [isLoadingValidateCodeForm]); + }, [isLoadingResendCodeForm]); /** * Check that all the form fields are valid, then trigger the submit callback @@ -314,7 +314,9 @@ function BaseValidateCodeForm(props) { success style={[styles.mv3]} text={props.translate('common.signIn')} - isLoading={props.account.isLoading && isLoadingValidateCodeForm} + isLoading={ + props.account.isLoading && props.account.loadingForm === (props.account.requiresTwoFactorAuth ? CONST.FORMS.VALIDATE_TFA_CODE_FORM : CONST.FORMS.VALIDATE_CODE_FORM) + } onPress={validateAndSubmitForm} /> From 1a8806c60a161159e8e16b215dd2af335a5f2d17 Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 18 Jul 2023 00:26:04 +0700 Subject: [PATCH 2/3] fix: change name --- src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js index 09efa7dc2de8..75003938feb4 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js @@ -89,7 +89,7 @@ function BaseValidateCodeForm(props) { const timerRef = useRef(); const hasError = Boolean(props.account) && !_.isEmpty(props.account.errors); - const isLoadingResendCodeForm = props.account.loadingForm === CONST.FORMS.RESEND_VALIDATION_FORM; + const isLoadingResendValidationForm = props.account.loadingForm === CONST.FORMS.RESEND_VALIDATION_FORM; useEffect(() => { if (!(inputValidateCodeRef.current && hasError && (props.session.autoAuthState === CONST.AUTO_AUTH_STATE.FAILED || props.account.isLoading))) { @@ -202,11 +202,11 @@ function BaseValidateCodeForm(props) { }; useEffect(() => { - if (!isLoadingResendCodeForm) { + if (!isLoadingResendValidationForm) { return; } clearLocalSignInData(); - }, [isLoadingResendCodeForm]); + }, [isLoadingResendValidationForm]); /** * Check that all the form fields are valid, then trigger the submit callback From e97e93d27f0fc83e0d3af923551bb67f938a5b4e Mon Sep 17 00:00:00 2001 From: tienifr Date: Tue, 18 Jul 2023 11:42:21 +0700 Subject: [PATCH 3/3] fix: change form name --- src/CONST.js | 1 + src/libs/actions/Session/index.js | 2 +- src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 88282c4b68e4..5206dde8664a 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -744,6 +744,7 @@ const CONST = { VALIDATE_TFA_CODE_FORM: 'ValidateTfaCodeForm', RESEND_VALIDATION_FORM: 'ResendValidationForm', UNLINK_LOGIN_FORM: 'UnlinkLoginForm', + RESEND_VALIDATE_CODE_FORM: 'ResendValidateCodeForm', }, APP_STATE: { ACTIVE: 'active', diff --git a/src/libs/actions/Session/index.js b/src/libs/actions/Session/index.js index 16f8e3f36403..abde90c853a9 100644 --- a/src/libs/actions/Session/index.js +++ b/src/libs/actions/Session/index.js @@ -172,7 +172,7 @@ function resendValidateCode(login = credentials.login) { key: ONYXKEYS.ACCOUNT, value: { errors: null, - loadingForm: CONST.FORMS.RESEND_VALIDATION_FORM, + loadingForm: CONST.FORMS.RESEND_VALIDATE_CODE_FORM, }, }, ]; diff --git a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js index 75003938feb4..41ee49b116c6 100755 --- a/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js +++ b/src/pages/signin/ValidateCodeForm/BaseValidateCodeForm.js @@ -89,7 +89,7 @@ function BaseValidateCodeForm(props) { const timerRef = useRef(); const hasError = Boolean(props.account) && !_.isEmpty(props.account.errors); - const isLoadingResendValidationForm = props.account.loadingForm === CONST.FORMS.RESEND_VALIDATION_FORM; + const isLoadingResendValidationForm = props.account.loadingForm === CONST.FORMS.RESEND_VALIDATE_CODE_FORM; useEffect(() => { if (!(inputValidateCodeRef.current && hasError && (props.session.autoAuthState === CONST.AUTO_AUTH_STATE.FAILED || props.account.isLoading))) {