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

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

Closed
anthony-hull opened this issue Aug 18, 2021 · 45 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@anthony-hull
Copy link
Contributor

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com 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 anthony-hull added AutoAssignerTriage Auto assign issues for triage to an available triage team member Daily KSv2 labels Aug 18, 2021
@MelvinBot
Copy link

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

@MelvinBot MelvinBot removed the AutoAssignerTriage Auto assign issues for triage to an available triage team member label Aug 18, 2021
@anthony-hull anthony-hull changed the title No error messages shown to user when setpassword gets and error from the API No error messages shown to user when setpassword gets an error from the API Aug 18, 2021
@anthony-hull
Copy link
Contributor Author

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

@marcaaron marcaaron changed the title No error messages shown to user when setpassword gets an error from the API [Network] No error messages shown to user when setpassword gets an error from the API Aug 21, 2021
@akshayasalvi
Copy link
Contributor

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

@MelvinBot
Copy link

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

@anthony-hull
Copy link
Contributor Author

I would modify:

function setPassword(password, validateCode, accountID) {
Onyx.merge(ONYXKEYS.ACCOUNT, {...CONST.DEFAULT_ACCOUNT_DATA, loading: true});
API.SetPassword({
password,
validateCode,
accountID,
})
.then((response) => {
if (response.jsonCode === 200) {
createTemporaryLogin(response.authToken, response.encryptedAuthToken, response.email);
return;
}
// This request can fail if the password is not complex enough
Onyx.merge(ONYXKEYS.ACCOUNT, {error: response.message});
})
.finally(() => {
Onyx.merge(ONYXKEYS.ACCOUNT, {loading: false});
});
}

To resemble:
.catch((error) => {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal(error.message), loading: false});
});

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
Copy link
Contributor Author

anthony-hull commented Aug 24, 2021

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:

App/src/libs/API.js

Lines 222 to 251 in 8a5cf2d

.then((response) => {
// If we didn't get a 200 response from Authenticate we either failed to Authenticate with
// an expensify login or the login credentials we created after the initial authentication.
// In both cases, we need the user to sign in again with their expensify credentials
if (response.jsonCode !== 200) {
switch (response.jsonCode) {
case 401:
throw new Error('passwordForm.error.incorrectLoginOrPassword');
case 402:
// If too few characters are passed as the password, the WAF will pass it to the API as an empty
// string, which results in a 402 error from Auth.
if (response.message === '402 Missing partnerUserSecret') {
throw new Error('passwordForm.error.incorrectLoginOrPassword');
}
throw new Error('passwordForm.error.twoFactorAuthenticationEnabled');
case 403:
throw new Error('passwordForm.error.invalidLoginOrPassword');
case 404:
throw new Error('passwordForm.error.unableToResetPassword');
case 405:
throw new Error('passwordForm.error.noAccess');
case 413:
throw new Error('passwordForm.error.accountLocked');
default:
throw new Error('passwordForm.error.fallback');
}
}
return response;
});
}

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
Copy link
Contributor Author

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

@MelvinBot
Copy link

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

@MelvinBot
Copy link

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

@tjferriss
Copy link
Contributor

@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?

@MelvinBot MelvinBot removed the Overdue label Aug 31, 2021
@akshayasalvi
Copy link
Contributor

@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 #4737 (comment)

@tjferriss
Copy link
Contributor

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.

@MelvinBot
Copy link

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

@tjferriss tjferriss removed their assignment Aug 31, 2021
@chiragsalian chiragsalian added the External Added to denote the issue can be worked on by a contributor label Sep 1, 2021
@MelvinBot MelvinBot added Weekly KSv2 and removed Daily KSv2 labels Sep 1, 2021
@MelvinBot
Copy link

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

@MelvinBot MelvinBot removed the Overdue label Sep 13, 2021
@kadiealexander
Copy link
Contributor

Hired you in Upwork @akshayasalvi, sorry for the oversight there!

@chiragsalian chiragsalian added the Reviewing Has a PR in review label Sep 14, 2021
@akshayasalvi
Copy link
Contributor

Thanks a lot @kadiealexander. No worries :)

@kadiealexander
Copy link
Contributor

Hi @akshayasalvi, I've placed this issue on hold as per this update, as we are prioritising issues related to a feature release scheduled for 9/24. As an apology for the delay, we will add a $100 bonus as a thank you for waiting.

@MelvinBot
Copy link

@chiragsalian, @akshayasalvi, @kadiealexander Whoops! This issue is 2 days overdue. Let's get this updated quick!

@chiragsalian
Copy link
Contributor

chiragsalian commented Sep 23, 2021

On n-6 hold melvin. Shoo.

Edit i just noticed its daily, doesn't make sense for something thats on hold to be daily. Demoting to weekly.

@chiragsalian chiragsalian added Weekly KSv2 and removed Daily KSv2 labels Sep 25, 2021
@kadiealexander
Copy link
Contributor

Please refer to this post for updated information on the n6 hold, we've raised the bonus to $250 for all issues where a PR is created before the N6 hold is lifted.

@kadiealexander
Copy link
Contributor

Hold has been removed, please go for gold @akshayasalvi!!

@MelvinBot MelvinBot added Monthly KSv2 and removed Weekly KSv2 labels Nov 15, 2021
@MelvinBot
Copy link

This issue has not been updated in over 15 days. @chiragsalian, @akshayasalvi, @kadiealexander eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@botify botify added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Monthly KSv2 labels Jan 4, 2022
@botify botify changed the title [Network] No error messages shown to user when setpassword gets an error from the API [HOLD for payment 2022-01-11] [Network] No error messages shown to user when setpassword gets an error from the API Jan 4, 2022
@botify
Copy link

botify commented Jan 4, 2022

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.1.24-19 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2022-01-11. 🎊

@kadiealexander
Copy link
Contributor

Paid, thanks @akshayasalvi!!

@akshayasalvi
Copy link
Contributor

@kadiealexander This PR was on n6-hold and company offsite hold. Bonus for the same wasn’t added

@kadiealexander
Copy link
Contributor

Oops, sorry for missing that one! Have issued the bonus now. :)

@akshayasalvi
Copy link
Contributor

Thanks a lot, @kadiealexander for helping here.

@anthony-hull
Copy link
Contributor Author

@kadiealexander Should I have had a reporting bonus for this issue?

@kadiealexander
Copy link
Contributor

Hey Anthony! The reporting bonus came into effect in September last year, a few weeks after this issue was raised. (Link to Slack post). The post is clear about issues raised before this date not qualifying for the reporting bonus, but if you think this should be reassessed for this issue please raise the question in #expensify-open-source to have the team review this. :)

@anthony-hull
Copy link
Contributor Author

no worries! thanks for the info :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

8 participants