Expensify / App

Welcome to New Expensify: a complete re-imagination of financial collaboration, centered around chat. Help us build the next generation of Expensify by sharing feedback and contributing to the code.
https://new.expensify.com
MIT License
3.14k stars 2.63k forks source link

[HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [$250] 2FA – Two-factor authentication step 1 appears briefly when open 2FA option if it is enabled #43807

Open lanitochka17 opened 1 month ago

lanitochka17 commented 1 month ago

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.84-0 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: N/A Email or phone of affected tester (no customers): ponikarchuks+315324@gmail.com Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to https://staging.new.expensify.com/
  2. Log in as a user with 2FA
  3. Open Account settings / Security options
  4. Click on Two-factor authentication

Expected Result:

Two-factor authentication enabled page open

Actual Result:

2FA step 1 appears briefly then Two-factor authentication enabled page open

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

Screenshots/Videos

Add any screenshot/video evidence

https://github.com/Expensify/App/assets/78819774/99148d5f-dbbd-4ce9-981a-c436020f83dd

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~015c346b94975326f0
  • Upwork Job ID: 1805943619282686764
  • Last Price Increase: 2024-06-26
  • Automatic offers:
    • bernhardoj | Contributor | 102893151
Issue OwnerCurrent Issue Owner: @muttmuure
melvin-bot[bot] commented 1 month ago

Triggered auto assignment to @muttmuure (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

lanitochka17 commented 1 month ago

We think that this bug might be related to #vip-vsp

lanitochka17 commented 1 month ago

@muttmuure FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

eucool commented 1 month ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

Two-factor authentication step 1 appears briefly when open 2FA option if it is enabled

What is the root cause of that problem?

We use a useState to assign the current step (success/enabled/disabled) for two factor auth, the initial value set for this is CONST.TWO_FACTOR_AUTH_STEPS.CODES.

We also use a useEffect to determine the value of this step. But for the very first time, the default value will be set to CONST.TWO_FACTOR_AUTH_STEPS.CODES and then the useEffect would run to determine the actual step.

But now as the default value was codes step, this case would be set to true and we would see the step 1 briefly and then the useEffect would set the correct step.

This is the root cause

What changes do you think we should make in order to solve the problem?

We should set the default value to null and let the useEffect fetch the correct step for us.

What alternative solutions did you explore? (Optional)

bernhardoj commented 1 month ago

Proposal

Please re-state the problem that we are trying to solve in this issue.

The 2FA page shows the code page briefly when opening it.

What is the root cause of that problem?

The initial value/state of the current step to render is the codes page. https://github.com/Expensify/App/blob/75c104bfe009ef937bcd129a35bb5a2e52f4339d/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx#L26

Then, we have this useEffect which will get the correct step. https://github.com/Expensify/App/blob/75c104bfe009ef937bcd129a35bb5a2e52f4339d/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx#L32-L43

What changes do you think we should make in order to solve the problem?

Instead of using both useState and useEffect, we can use useMemo.

const currentStep = useMemo(() => {
    if (account?.twoFactorAuthStep) {
        return account.twoFactorAuthStep;
    }
    return account?.requiresTwoFactorAuth ? CONST.TWO_FACTOR_AUTH_STEPS.ENABLED : CONST.TWO_FACTOR_AUTH_STEPS.CODES;
}, [account?.requiresTwoFactorAuth, account?.twoFactorAuthStep]);

Then, we can remove the setCurrentStep from handleSetStep because TwoFactorAuthActions.setTwoFactorAuthStep will update the current step which will trigger the memo above. https://github.com/Expensify/App/blob/75c104bfe009ef937bcd129a35bb5a2e52f4339d/src/pages/settings/Security/TwoFactorAuth/TwoFactorAuthSteps.tsx#L45-L49

muttmuure commented 4 weeks ago

Not overdue

melvin-bot[bot] commented 3 weeks ago

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

melvin-bot[bot] commented 2 weeks ago

Job added to Upwork: https://www.upwork.com/jobs/~015c346b94975326f0

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to Contributor-plus team member for initial proposal review - @thesahindia (External)

thesahindia commented 2 weeks ago

@bernhardoj's proposal looks good!

🎀 👀 🎀 C+ reviewed

melvin-bot[bot] commented 2 weeks ago

Triggered auto assignment to @yuwenmemon, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

melvin-bot[bot] commented 2 weeks ago

📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link Upwork job Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻 Keep in mind: Code of Conduct | Contributing 📖

bernhardoj commented 2 weeks ago

PR is ready

cc: @thesahindia

melvin-bot[bot] commented 6 days ago

Reviewing label has been removed, please complete the "BugZero Checklist".

melvin-bot[bot] commented 6 days ago

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

If no regressions arise, payment will be issued on 2024-07-17. :confetti_ball:

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 6 days ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

bernhardoj commented 6 days ago

I'll request in ND once payment is due.

thesahindia commented 1 day ago

It was implemented like this in the beginning then the code was changed but it got reverted by https://github.com/Expensify/App/pull/31738 because of regressions so there's no specific PR responsible for this.

We don't have to add a test case for this but if we want here are the steps:-

Prerequisite: 2FA enabled

  1. Open Settings > Security > 2FA
  2. Verify the code step (or the 1st step) doesn't show briefly and instead shows the enabled page
melvin-bot[bot] commented 1 day ago

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

If no regressions arise, payment will be issued on 2024-07-22. :confetti_ball:

For reference, here are some details about the assignees on this issue:

melvin-bot[bot] commented 1 day ago

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

bernhardoj commented 1 day ago

Payment should be due tomorrow (07-17)

bernhardoj commented 3 hours ago

Requested in ND.