Repository navigation
Closed
Labels
EngineeringImprovementItem broken or needs improvement.InternalRequires API changes or must be handled by Expensify staffWeeklyKSv2
Description
Problem:
- When we call
API.SetPassword()we are creating a temp login when the response is 200 - Otherwise we set the generic server error
- We also have a
catch()that is handling a reponse... but it's not clear where that response would come from. - SetPassword itself doesn't have any specific handling to throw a response
- There's also a check for a
Validate code failedmessage that is unlikely to be attached to an error since errors have no title (unless we throw the response itself - which we don't do) - Mostly, it just looks like a misunderstanding about how
catch()even works or it could be possible we were throwing an error that we weren't catching increateTemporaryLogin()at some point (unlikely)
Solution:
I think at a minimum this logic needs to be migrated out of this catch() block as we are never going to hit it with the expected parameters and the logic makes no sense at all.
App/src/libs/actions/Session/index.js
Lines 319 to 332 in 6c53be1
| .catch((response) => { | |
| if (response.title !== CONST.PASSWORD_PAGE.ERROR.VALIDATE_CODE_FAILED) { | |
| return; | |
| } | |
| const login = lodashGet(response, 'data.email', null); | |
| Onyx.merge(ONYXKEYS.ACCOUNT, {accountExists: true, validateCodeExpired: true, error: null}); | |
| // The login might not be set if the user hits a url in a new session. We set it here to ensure calls to resendValidationLink() will succeed. | |
| if (login) { | |
| Onyx.merge(ONYXKEYS.CREDENTIALS, {login}); | |
| } | |
| Navigation.navigate(ROUTES.HOME); | |
| }) |
There are some side effects being performed in the catch like navigating back to home and making sure the resend validate code logic works, but unclear which flows that code was intended to fix. Will check git blames and try to piece it together 😄
catch() in general seems to be poorly understood throughout the app, but that is a separate issue...
Metadata
Metadata
Assignees
Labels
EngineeringImprovementItem broken or needs improvement.InternalRequires API changes or must be handled by Expensify staffWeeklyKSv2
Activity
marcaaron commentedon Apr 18, 2022
We also just do this when the validate code expires and a user tries to set a password which should be updated to use
FormAlertWithSubmitButton