Skip to content

Commit

Permalink
check for account.isLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
arosiclair committed Jan 22, 2024
1 parent 95f6022 commit 454c2b1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/pages/signin/SAMLSignInPage/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ const propTypes = {
/** The email/phone the user logged in with */
login: PropTypes.string,
}),

/** State of the logging in user's account */
account: PropTypes.shape({
/** Whether the account is loading */
isLoading: PropTypes.bool,
}),
};

const defaultProps = {
credentials: {},
account: {},
};

function SAMLSignInPage({credentials}) {
function SAMLSignInPage({credentials, account}) {
const samlLoginURL = `${CONFIG.EXPENSIFY.SAML_URL}?email=${credentials.login}&referer=${CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER}&platform=${getPlatform()}`;
const [showNavigation, shouldShowNavigation] = useState(true);

Expand All @@ -44,7 +51,7 @@ function SAMLSignInPage({credentials}) {
}

const searchParams = new URLSearchParams(new URL(url).search);
if (searchParams.has('shortLivedAuthToken')) {
if (searchParams.has('shortLivedAuthToken') && !account.isLoading) {
Log.info('SAMLSignInPage - Successfully received shortLivedAuthToken. Signing in...');
const shortLivedAuthToken = searchParams.get('shortLivedAuthToken');
Session.signInWithShortLivedAuthToken(credentials.login, shortLivedAuthToken);
Expand All @@ -57,7 +64,7 @@ function SAMLSignInPage({credentials}) {
Navigation.navigate(ROUTES.HOME);
}
},
[credentials.login, shouldShowNavigation],
[credentials.login, shouldShowNavigation, account.isLoading],
);

return (
Expand Down Expand Up @@ -95,4 +102,5 @@ SAMLSignInPage.displayName = 'SAMLSignInPage';

export default withOnyx({
credentials: {key: ONYXKEYS.CREDENTIALS},
account: {key: ONYXKEYS.ACCOUNT},
})(SAMLSignInPage);

0 comments on commit 454c2b1

Please sign in to comment.