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

Sign in, out, or navigate on transition mount #8257

Merged
merged 14 commits into from
Mar 23, 2022
Merged
20 changes: 1 addition & 19 deletions src/pages/LogInWithShortLivedTokenPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,12 @@ class LogInWithShortLivedTokenPage extends Component {
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', '');

// 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
return;
Expand Down Expand Up @@ -121,10 +109,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);