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

Handle unauthenticated users when creating a new workspace #3578

Merged
merged 6 commits into from
Jun 14, 2021

Conversation

Beamanator
Copy link
Contributor

@Beamanator Beamanator commented Jun 14, 2021

Details

If an unauthenticated user navigates to https://expensify.cash/workspace/new, we redirect them to the signin page and, after signing in, send them back to https://expensify.cash/workspace/new.

cc @marcaaron

Fixed Issues

Fixes https://github.com/Expensify/Expensify/issues/166528

Tests

  1. Open e.cash and log out
  2. Manually navigate to http://localhost:8080/workspace/new
  3. Sign in normally
  4. Notice you get redirected to http://localhost:8080/workspace/new again, but since you're authenticated you see the actual new workspace page!

QA Steps

  1. Open e.cash and log out
  2. Manually navigate to https://staging.expensify.cash/workspace/new
  3. Sign in normally
  4. Notice you get redirected to https://staging.expensify.cash/workspace/new again, but since you're authenticated you see the actual new workspace page!

Tested On

Screenshots

Web

Screen.Recording.2021-06-14.at.7.27.09.PM.mov

Mobile Web

Screen.Recording.2021-06-14.at.7.29.10.PM.mov

Desktop

N/A

iOS

N/A

Android

N/A

@Beamanator Beamanator self-assigned this Jun 14, 2021
@Beamanator Beamanator requested a review from a team as a code owner June 14, 2021 16:53
@Beamanator Beamanator marked this pull request as draft June 14, 2021 16:53
@MelvinBot MelvinBot requested review from Gonals and removed request for a team June 14, 2021 16:54
@Beamanator Beamanator marked this pull request as ready for review June 14, 2021 17:33
class PublicWorkspaceNewView extends React.PureComponent {
componentDidMount() {
Onyx.merge(ONYXKEYS.SESSION, {redirectToWorkspaceNewAfterSignIn: true});
this.props.navigation.replace(SCREENS.HOME);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: Had to use this.props.navigation instead of src/libs/Navigation/Navigation -> navigate because navigationRef didn't exist immediately when navigating to /workspace/new

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that's interesting and I'd be curious to know more about why that is so we can standardize on this.props.navigtation or Navigation.navigate() and not have to use a combination of them. But this works ok for now I think. Maybe we can create a follow up to figure it out at some point.

@marcaaron marcaaron self-requested a review June 14, 2021 17:52
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.

LGTM and works well thanks for the fast work @Beamanator

},
Onyx.merge(ONYXKEYS.SESSION, {
shouldShowComposeInput: true,
..._.pick(data, 'authToken', 'accountID', 'email'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I can see why this needed to be switched from multiSet() to merge(), but curious if there are reasons why we were using the set behavior over the merge behavior and if anything unexpected will come from this change (I'm not really sure so maybe it's a NAB - but sort of unclear why we used one over the other in the first place).

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 was thinking about that, my assumption is that since it was done 7 months ago, we just didn't "need to" do .merge yet. I can keep an eye on issues related to Session storage in the next few weeks just in case

class PublicWorkspaceNewView extends React.PureComponent {
componentDidMount() {
Onyx.merge(ONYXKEYS.SESSION, {redirectToWorkspaceNewAfterSignIn: true});
this.props.navigation.replace(SCREENS.HOME);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, that's interesting and I'd be curious to know more about why that is so we can standardize on this.props.navigtation or Navigation.navigate() and not have to use a combination of them. But this works ok for now I think. Maybe we can create a follow up to figure it out at some point.

@marcaaron marcaaron merged commit 7186caf into main Jun 14, 2021
@marcaaron marcaaron deleted the beaman-handle-new-workspace-for-nonauth-users branch June 14, 2021 18:07
@OSBotify
Copy link
Contributor

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

@OSBotify
Copy link
Contributor

🚀 Deployed to staging in version: 1.0.68-5🚀

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

@OSBotify
Copy link
Contributor

🚀 Deployed to production in version: 1.0.73-3🚀

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

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.

3 participants