Skip to content

SetPassword logic needs improvement #8678

Closed

Description

@marcaaron

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 failed message 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 in createTemporaryLogin() 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.

.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...

Activity

  1. added
    Weekly
    Improvement
    Internal
    on Apr 18, 2022
  2. self-assigned this
    on Apr 18, 2022
  3. marcaaron commented on Apr 18, 2022

    @marcaaron
    ContributorAuthor

    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

    2022-04-18_10-38-46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

EngineeringImprovementInternalWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions