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

Allow e.com to link straight to e.cash and share sessions #3715

Merged
merged 27 commits into from
Jul 8, 2021

Conversation

tgolen
Copy link
Contributor

@tgolen tgolen commented Jun 21, 2021

Fixed Issues

Done along with: https://github.com/Expensify/Web-Expensify/pull/31302
Fixes https://github.com/Expensify/Expensify/issues/162554

Tests / QA

  1. Be sure you're signed out of e.cash
  2. Sign into e.com with a brand new account on a domain WITHOUT two-factor authentication
  3. Complete the inbox task "What will you use Expensify for? Choose as many as you'd like!" and ONLY choose the expensify card
  4. Verify that you are automatically logged into e.cash and are seeing the page to create a new workspace

Now, test it out with 2FA

  1. Be sure you're signed out of e.cash
  2. Sign into e.com with a brand new account on a domain WITH two-factor authentication enabled
  3. Complete the inbox task "What will you use Expensify for? Choose as many as you'd like!" and ONLY choose the expensify card
  4. Verify that you are redirected to e.cash to ever a 2FA code
  5. After the code is entered, verify you are automatically logged into e.cash and are seeing the page to create a new workspace

Tested On

No other platforms need to be tested because this flow only works on web (the inbox task isn't shown on mobile at all)

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

image

cc @marcaaron @TomatoToaster

@tgolen tgolen self-assigned this Jun 21, 2021
@tgolen tgolen changed the title Allow e.com to link straight to e.cash and share sessions [HOLD Web-E #31302] Allow e.com to link straight to e.cash and share sessions Jul 2, 2021
@tgolen tgolen requested a review from a team July 2, 2021 18:07
@MelvinBot MelvinBot requested review from Dal-Papa and removed request for a team July 2, 2021 18:07
@tgolen
Copy link
Contributor Author

tgolen commented Jul 2, 2021

This is all working, but the redirect to the new-workspace page is causing several JS console warnings:

image

They don't appear to be affecting anything, but I haven't been able to figure out what the deal is. My guess is that it's related to running these back-to-back:

            Navigation.dismissModal();
            Navigation.navigate(ROUTES.WORKSPACE_NEW);

and I think there is a race condition because I think part of the code inside dismissModal() is async, but it's hard to figure out when exactly dismissModal() is finished doing its thing. There is one existing flow that uses this same dismiss->navigate pattern here: https://github.com/Expensify/Expensify.cash/blob/099457ec41f238be8103d953e4c8b50ea2b030f1/src/libs/actions/Policy.js#L201-L202

I'm not sure what to do about this. We need to have this code deployed by Jul 9, so I am thinking that we merge this as-is, and then open up an issue for improving this dismiss->navigate pattern.

@tgolen tgolen marked this pull request as ready for review July 2, 2021 18:14
@tgolen tgolen requested a review from a team as a code owner July 2, 2021 18:14
@MelvinBot MelvinBot requested review from alex-mechler and removed request for a team July 2, 2021 18:14
Copy link
Contributor

@marcaaron marcaaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes LGTM! I'm not sure whether there is any problem with the dismiss + navigate pattern (it seems kosher to me). But I agree that the react warning is not a blocker. Could be an issue is withOnyx() not having any awareness that its children have unmounted - I've observed similar issues before, but hard to say without debugging.

if (this.props.session.authToken) {
// In order to navigate to a modal, we first have to dismiss the current modal. But there is no current
// modal you say? I know, it confuses me too. Without dismissing the current modal, if they user cancels
// out of the new workspace modal, then they will be routed back to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there is no current modal you say? I know, it confuses me too.

NAB, I can see how this could be confusing (because the modal is not visible), but I think maybe it's not that mysterious. Curious if we should replace this commentary with a better explanation and have an idea about what's happening here...

ValidateLogin2FANewWorkspacePage is the modal we are dismissing, it "exists", but the page is returning null. So that's why we need to remove it from the history stack or else when we "goBack()" we will navigate to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm all in favor of updating this comment to make more sense. If the real problem is that ValidateLogin2FANewWorkspacePage is in the history stack, maybe there is a better way for us to remove it from the stack without needing to call dismissModal()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe there is a better way for us to remove it from the stack without needing to call dismissModal()

I'm having trouble working out a better way. It feels like there are contexts where you'd want the default navigate() method to preserve the underlying modal in the stack e.g. moving from /settings to /settings/payments and contexts where you'll want a different behavior. We could maybe add a parameter to navigate() that forces all other modals to close?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right, I was able to fix this. Turns out, I was navigating to that modal twice (once in Session, and again from ComponentDidMount (from when the same page was remounted: once in public screens and then again in auth screens).

Once I removed the navigation in the Session action, it all worked like a charm.

@tgolen tgolen changed the title [HOLD Web-E #31302] Allow e.com to link straight to e.cash and share sessions Allow e.com to link straight to e.cash and share sessions Jul 2, 2021
@tgolen
Copy link
Contributor Author

tgolen commented Jul 2, 2021

I removed the hold because this actually needs to be deployed first, before the web-e change.

@tgolen
Copy link
Contributor Author

tgolen commented Jul 6, 2021

All right, thanks for the reviews! I updated it and addressed everything as well as fixing the initial warnings that I was struggling with. Should be ready for another review.

* @param {String} parameters.accountID
* @param {String} parameters.validateCode
* @param {String} [parameters.twoFactorAuthCode]
* @returns {Promise<unknown>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB / just curious but why Promise<unknown>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think PHPStorm did that automatically, so I'm not sure why! I'll remove it

},
headerShown: false,
animationTypeForReplace: 'pop',
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like defaultScreenOptions is also declared in PublicScreens.js with the same values. Maybe they should be moved into a separate config file so we don't have to remember to update things twice in the future when applying a change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can do that.

@tgolen
Copy link
Contributor Author

tgolen commented Jul 6, 2021

Updated to DRY up the default screen options.

@alex-mechler
Copy link
Contributor

I'm trying to test this out, and Web-E redirects me to the correct link, but then I am redirect to the homepage without any error messages. Is there any additional setup I have to do that is not mentioned in the testing steps?

Dal-Papa
Dal-Papa previously approved these changes Jul 7, 2021
@tgolen
Copy link
Contributor Author

tgolen commented Jul 7, 2021

@alex-mechler I don't think there is anything special you need to do, no.

Just so I am clear, the test steps work for except that instead of seeing the new-workspace page, you see the home page?

@alex-mechler
Copy link
Contributor

Correct. I am not automatically logged into e.cash, and do not see the new workspace page. I checked out the branch from https://github.com/Expensify/Web-Expensify/pull/31302 and this branch. Is there any other branches I need to checkout? Was there any auth changes that I might be missing?

alex-mechler
alex-mechler previously approved these changes Jul 7, 2021
Copy link
Contributor

@alex-mechler alex-mechler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out my auth was out of date 😅

Works well, two NABs, feel free to merge if you don't think they are worth fixing

@@ -268,6 +268,7 @@ export default {
},
passwordForm: {
pleaseFillOutAllFields: 'Please fill out all fields',
enterATwoFactorAuthenticationCodeToContinue: 'Enter a two factor authentication code to continue',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: I feel like your reads better than a here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can change this.

success
style={[styles.mb2]}
text={this.props.translate('common.continue')}
isLoading={this.state.loading}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: We never set this anywhere but the constructor, meaning the user has no feedback as to when we are actually loading

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll see about cleaning this up.

@tgolen tgolen dismissed stale reviews from alex-mechler and Dal-Papa via f9f3c61 July 7, 2021 21:52
@tgolen
Copy link
Contributor Author

tgolen commented Jul 7, 2021

OK, I updated to change the language on the form prompt and to display the loading indicator when the 2FA is being validated.

@tgolen
Copy link
Contributor Author

tgolen commented Jul 8, 2021

I'm gonna go ahead and merge since the other reviewers approved already and the changes since then were minor.

@tgolen tgolen merged commit 2bda7d6 into main Jul 8, 2021
@tgolen tgolen deleted the tgolen-validate-redirect branch July 8, 2021 14:08
@tgolen
Copy link
Contributor Author

tgolen commented Jul 8, 2021

Once this goes to production, we can merge Expensify/Web-Expensify#31302

@OSBotify
Copy link
Contributor

OSBotify commented Jul 8, 2021

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@kavimuru
Copy link

User is not automatically logged into e.cash after completing the inbox task

Expected Result:

Scenario 1: ​Verify that you are automatically logged into e.cash and are seeing the page to create a new workspace
Scenario 2: Verify that you are redirected to e.cash to ever a 2FA code

Actual Result:

Not automatically logged into e.cash and the page to create a new workspace isn't shown. User is redirected to sign in page for both the scenarios

Actions Performed:

Scenario1:

  1. Be sure you're signed out of e.cash
  2. Sign into e.com with a brand new account on a domain WITHOUT two-factor authentication
  3. Complete the inbox task "What will you use Expensify for? Choose as many as you'd like!" and ONLY choose the expensify card

Scenario2:

  1. Be sure you're signed out of e.cash
  2. Sign into e.com with a brand new account on a domain WITH two-factor authentication enabled
  3. Complete the inbox task "What will you use Expensify for? Choose as many as you'd like!" and ONLY choose the expensify card

Platform:

Web ✔️
iOS
mWeb
Android

Build:

1.0.77-0

Notes/Images/Video:

Bug5147298_Screen_Shot_2021-07-10_at_7 30 21_PM

Bug5147298_Screen_Shot_2021-07-10_at_7 35 37_PM

@tgolen
Copy link
Contributor Author

tgolen commented Jul 12, 2021

Ah, I think that's expected for now. Sorry, this issue should be production QA and internal QA (because it requires being in a beta for it to work). It also needs to have https://github.com/Expensify/Web-Expensify/pull/31302 deployed, and it looks like that still hasn't been.

@isagoico
Copy link

Perfect! will check the PR off the list then. Thanks 🙇

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.77-5🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@TomatoToaster
Copy link
Contributor

TomatoToaster commented Jul 15, 2021

ITS WORKING!!
I got redirected from expensify after choosing just expensify card on the business inbox task.
image

@tgolen
Copy link
Contributor Author

tgolen commented Jul 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants