App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2022-01-11] [Network] No error messages shown to user when setpassword gets an error from the API

Open anthony-hull opened this issue 5 years ago • 45 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

sign up as a new user and click the link. Delete the last character of the url and navigate.

Expected Result:

An error should be shown to the user explaining why the request didn't work. In this case say the key has likely expired and a new one will be waiting in their emails. I would also expect the email from expensify to be another link to new.expensify.com to finish the set password flow

Actual Result:

https://user-images.githubusercontent.com/47184118/129949187-00c5b590-ca4e-4a7a-abee-54b49ece9952.mp4 the second email has a link to the old expensify password reset flow, not to the new.expensify.com/setpassword/.../...

Workaround:

User would have to guess what went wrong (I'm simulating an expired token). User would have to check emails finish the flow in the old site and then navigate to the new site.

Platform:

  • Web
  • iOS
  • Android
  • Desktop App
  • Mobile Web

View all open jobs on GitHub

anthony-hull avatar Aug 18 '21 18:08 anthony-hull

Triggered auto assignment to @tjferriss (AutoAssignerTriage), see https://stackoverflow.com/c/expensify/questions/4749 for more details.

MelvinBot avatar Aug 18 '21 18:08 MelvinBot

should I made another issue for the API not sending the correct link out or will that get one made internally somewhere else?

anthony-hull avatar Aug 18 '21 18:08 anthony-hull

I reported a duplicate issue it seems. I am proposing the following solution.

Proposed Solution

Add a catch block to setPassword API:

function setPassword(password, validateCode, accountID) {
  Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true});

  API.SetPassword({
    password,
    validateCode,
    accountID,
  })
    .then((response) => {
         /// existing code
    })
    .catch((err) => { 
        Onyx.merge(ONYXKEYS.ACCOUNT, {error: err.message});
    })
   // existing code
}

image

akshayasalvi avatar Aug 21 '21 01:08 akshayasalvi

@tjferriss Huh... This is 4 days overdue. Who can take care of this?

MelvinBot avatar Aug 23 '21 19:08 MelvinBot

I would modify: https://github.com/Expensify/App/blob/8a5cf2d190e8e259a1bcb4090fcb437e42f78dbe/src/libs/actions/Session.js#L261-L281 To resemble: https://github.com/Expensify/App/blob/8a5cf2d190e8e259a1bcb4090fcb437e42f78dbe/src/libs/actions/Session.js#L229-L231

Where the error handling would be in a catch block. I'm not familiar with translateLocal yet. I would look at using this on the error as well.

anthony-hull avatar Aug 24 '21 10:08 anthony-hull

I had a look at how API.js handles it and we have a bunch of switch cases to cover off giving the right translated strings in the Errors to give to translateLocal: https://github.com/Expensify/App/blob/8a5cf2d190e8e259a1bcb4090fcb437e42f78dbe/src/libs/API.js#L222-L251

Do we have such sophistication of HTTP codes for this API call?

For a simple fix I can just use the message in the API response to display. But to bring this upto standard with the rest of the app with translations I need a mapping of the different HTTP error codes to copy.

anthony-hull avatar Aug 24 '21 10:08 anthony-hull

The API response not being translated should be its own issue. I'll make one later :)

anthony-hull avatar Aug 25 '21 15:08 anthony-hull

@tjferriss 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

MelvinBot avatar Aug 25 '21 19:08 MelvinBot

@tjferriss 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

MelvinBot avatar Aug 27 '21 19:08 MelvinBot

@akshayasalvi can you link to the duplicate issue you previously mentioned? If you're working on a solution there then can we close this issue?

tjferriss avatar Aug 31 '21 14:08 tjferriss

@tjferriss the issue is #4745 . I am not working on it at the moment. One of your team member asked me to apply to this issue and closed the other one .

here’s my proposal for the same https://github.com/Expensify/App/issues/4737#issuecomment-903034853

akshayasalvi avatar Aug 31 '21 15:08 akshayasalvi

Thanks for referencing it and sorry for the delay here. I'm going to tag engineering so someone can take a look and remove my assignment.

tjferriss avatar Aug 31 '21 21:08 tjferriss

Triggered auto assignment to @chiragsalian (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Aug 31 '21 21:08 MelvinBot

Triggered auto assignment to @kadiealexander (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Sep 01 '21 19:09 MelvinBot

Nice issue. Yes, let's improve it.

should I made another issue for the API not sending the correct link out or will that get one made internally somewhere else?

I don't follow. Can you explain this API? If its for a new link, that's not needed, we have the email in localStorage and when you redirect to the screen i mentioned below you would use the same email.

But to bring this upto standard with the rest of the app with translations I need a mapping of the different HTTP error codes to copy.

We unfortunately do not have such mapping.

I'm not sure I'm a fan of either solution. The solution posts an error message but does not help the user with their next step. The behavior of the solution should be very similar to what we do in expensify.com i.e., when the validate code is incorrect we show, image

So the copy we want to use is -

It looks like there was an error with your validation link. Either the validation link has expired, or your account does not exist.

So this means for newDot we'll want to redirect to this screen with the correct error message, image

With that in mind can you guys come up with an updated proposal?

chiragsalian avatar Sep 01 '21 19:09 chiragsalian

Updated Proposal

Based on the feedback, we could do the following:

function setPassword(password, validateCode, accountID) {
  Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true});

  API.SetPassword({
    password,
    validateCode,
    accountID,
  })
    .then((response) => {
         /// existing code

      
    })
    .catch((err) => { 
        if(err.statusCode === 404) {
            Onyx.merge(ONYXKEYS.ACCOUNT, { hasValidationCodeError: true});
            Navigation.navigate(ROUTES.HOME);
        }
        
    })
   // existing code
}

and in the SigninPage


const validAccount = this.props.account.accountExists
            && this.props.account.validated
            && !this.props.account.forgotPassword && !this.props.account.hasValidationCodeError;

const hasValidationCodeError = this.props.credentials.login
            && !validAccount
            && this.props.account.hasValidationCodeError


const welcomeText = this.props.translate(`${hasValidationCodeError ? 'resendValidationForm.validationCodeExpired': `welcomeText.${showPasswordForm ? 'phrase4' : 'phrase1'`);

{showResendValidationLinkForm && <ResendValidationForm  />}

and finally, update the translations:

  en: {
     resendValidationForm: {
         validationCodeExpired: 'It looks like there was an error with your validation link. Either the validation link has expired, or your account does not exist.'
     },
  },
  es: {
         resendValidationForm: {
              validationCodeExpired:'Spanish Translation'
         }
  }


One suggestion is that the text message looks too big. Can we shorten it a bit?

akshayasalvi avatar Sep 01 '21 21:09 akshayasalvi

Upwork post: https://www.upwork.com/jobs/~019934453904b5ea8f

kadiealexander avatar Sep 02 '21 04:09 kadiealexander

@akshayasalvi, nice i like that direction. Few suggestions:

  1. I don't see the need for hasValidationCodeError boolean when we already have this.props.account.validated that we can reuse. This would clean up the logic of validAccount and not need hasValidationCodeError.
  2. With the changes from above if we don't pass hasValidationCodeError we can instead pass a string validationFailedMessage (maybe check if you can reuse account.error first before this new key). This can be reused in the future too if needed and cleans up some of the current logic. So with those changes, i would suggest doing,
Onyx.merge(ONYXKEYS.ACCOUNT, { validated: false, validationFailedMessage: 'resendValidationForm.validationCodeExpired'});
  1. Next the welcomeText variable is not very readable in my opinion. Having double ternary operator in a single line is not very readable so if we pass resendValidationForm.validationCodeExpired as validationFailedMessage then we can clean this up like so,
const welcomeText = this.props.translate(this.props.account.validationFailedMessage ?? (`welcomeText.${showPasswordForm ? 'phrase4' : 'phrase1'}`));
  1. But while we can clean that up as I think about this, we shouldn't be editing the welcomeText. In fact i think welcomeText should be blank and we should instead update the code here to display resendValidationForm.validationCodeExpired instead of resendValidationForm.weSentYouMagicSignInLink when validationFailedMessage contains a value i.e.,
this.props.account.validationFailedMessage ?? 'resendValidationForm.weSentYouMagicSignInLink'
  1. To answer "One suggestion is that the text message looks too big. Can we shorten it a bit?" I think its pretty small. Once we've got the PR up we can revisit the copy if it still looks too long in the UI.

Thoughts on these changes @akshayasalvi?

chiragsalian avatar Sep 02 '21 23:09 chiragsalian

Good points overall. I wasn't sure if we allow adding translation keys in Onyx. Agree with points 1, 2, 3, and 5.

Point 4, I feel without the title this page will look off compared to other pages. But let's try and see how it shows up. Sounds okay?

akshayasalvi avatar Sep 02 '21 23:09 akshayasalvi

Yup all those sounds good with me. @kadiealexander, can you hire @akshayasalvi in upwork. @akshayasalvi, feel free to go ahead and work on the PR.

chiragsalian avatar Sep 02 '21 23:09 chiragsalian