Skip to content

Commit

Permalink
Merge pull request Expensify#8278 from Expensify/OSBotify-cherry-pick…
Browse files Browse the repository at this point in the history
…-staging-8257

🍒 Cherry pick PR Expensify#8257 to staging 🍒
  • Loading branch information
OSBotify authored Mar 24, 2022
2 parents c731f91 + b443e09 commit 6a3d1a4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 31 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001014403
versionName "1.1.44-3"
versionCode 1001014404
versionName "1.1.44-4"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.44.3</string>
<string>1.1.44.4</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.44.3</string>
<string>1.1.44.4</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.44-3",
"version": "1.1.44-4",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
4 changes: 3 additions & 1 deletion src/libs/actions/WelcomeActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ function show({routes, toggleCreateMenu}) {
// If we are rendering the SidebarScreen at the same time as a workspace route that means we've already created a workspace via workspace/new and should not open the global
// create menu right now.
const topRouteName = lodashGet(_.last(routes), 'name', '');
const isDisplayingWorkspaceRoute = topRouteName.toLowerCase().includes('workspace');
const loginWithShortLivedTokenRoute = _.find(routes, route => route.name === 'LogInWithShortLivedToken');
const exitingToWorkspaceRoute = lodashGet(loginWithShortLivedTokenRoute, 'params.exitTo', '') === 'workspace/new';
const isDisplayingWorkspaceRoute = topRouteName.toLowerCase().includes('workspace') || exitingToWorkspaceRoute;

// It's also possible that we already have a workspace policy. In either case we will not toggle the menu but do still want to set the NVP in this case
// since the user does not need to create a workspace.
Expand Down
35 changes: 11 additions & 24 deletions src/pages/LogInWithShortLivedTokenPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ONYXKEYS from '../ONYXKEYS';
import * as Session from '../libs/actions/Session';
import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator';
import Navigation from '../libs/Navigation/Navigation';
import Log from '../libs/Log';

const propTypes = {
/** The parameters needed to authenticate with a short lived token are in the URL */
Expand Down Expand Up @@ -49,44 +50,35 @@ const defaultProps = {

class LogInWithShortLivedTokenPage extends Component {
componentDidMount() {
const accountID = parseInt(lodashGet(this.props.route.params, 'accountID', ''), 10);
const accountID = lodashGet(this.props.route.params, 'accountID', '');
const email = lodashGet(this.props.route.params, 'email', '');
const shortLivedToken = lodashGet(this.props.route.params, 'shortLivedToken', '');

const isUserSignedIn = this.props.session && this.props.session.authToken;
if (!isUserSignedIn) {
Log.info('[LoginWithShortLivedTokenPage] User not signed in - signing in with short lived token');
Session.signInWithShortLivedToken(accountID, email, shortLivedToken);
return;
}

this.signOutIfNeeded(email);
}

componentDidUpdate() {
if (!lodashGet(this.props, 'session.authToken', null)) {
if (this.signOutIfNeeded(email)) {
return;
}

const email = lodashGet(this.props.route.params, 'email', '');
Log.info('[LoginWithShortLivedTokenPage] User is signed in');

// exitTo is URI encoded because it could contain a variable number of slashes (i.e. "workspace/new" vs "workspace/<ID>/card")
const exitTo = decodeURIComponent(lodashGet(this.props.route.params, 'exitTo', ''));

if (this.signOutIfNeeded(email)) {
return;
}

if (exitTo === ROUTES.WORKSPACE_NEW) {
// New workspace creation is handled in AuthScreens, not in its own screen
Log.info('[LoginWithShortLivedTokenPage] exitTo is workspace/new - handling new workspace creation in AuthScreens');
return;
}

// 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 the user cancels out
// of the workspace modal, then they will be routed back to
// /transition/<accountID>/<email>/<authToken>/workspace/<policyID>/card and we don't want that. We want them to go back to `/`
// and by calling dismissModal(), the /transition/... route is removed from history so the user will get taken to `/`
// if they cancel out of the new workspace modal.
// In order to navigate to a modal, we first have to dismiss the current modal. Without dismissing the current modal, if the user cancels out of the workspace modal,
// then they will be routed back to /transition/<accountID>/<email>/<authToken>/workspace/<policyID>/card and we don't want that. We want them to go back to `/`
// and by calling dismissModal(), the /transition/... route is removed from history so the user will get taken to `/` if they cancel out of the new workspace modal.
Log.info('[LoginWithShortLivedTokenPage] Dismissing LoginWithShortLivedTokenPage and navigating to exitTo');
Navigation.dismissModal();
Navigation.navigate(exitTo);
}
Expand All @@ -105,6 +97,7 @@ class LogInWithShortLivedTokenPage extends Component {
return false;
}

Log.info('[LoginWithShortLivedTokenPage] Different user signed in - signing out');
Session.signOutAndRedirectToSignIn();
return true;
}
Expand All @@ -121,10 +114,4 @@ export default withOnyx({
session: {
key: ONYXKEYS.SESSION,
},

// We need to subscribe to the betas so that componentDidUpdate will run,
// causing us to exit to the proper page.
betas: {
key: ONYXKEYS.BETAS,
},
})(LogInWithShortLivedTokenPage);

0 comments on commit 6a3d1a4

Please sign in to comment.