fix: redirect required SAML users to SSO#93528
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@ZhenjaHorbach Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
| setHasInitiatedSAMLLogin(true); | ||
| Navigation.isNavigationReady().then(() => Navigation.navigate(ROUTES.SAML_SIGN_IN)); | ||
| } | ||
| useEffect(() => { |
There was a problem hiding this comment.
❌ PERF-15 (docs)
This useEffect calls Navigation.isNavigationReady().then(...) which performs side effects (setHasInitiatedSAMLLogin(true), mutation of hasPendingSAMLRedirectForCurrentSignIn, and Navigation.navigate(...)) inside the .then() callback. If shouldInitiateSAMLLogin toggles rapidly or the component unmounts before the promise resolves, the stale callback will still execute, potentially navigating to the SAML sign-in page after the effect is no longer relevant.
Add a cleanup mechanism using an ignore flag to prevent stale promise resolution:
useEffect(() => {
if (!shouldInitiateSAMLLogin) {
return;
}
let ignore = false;
Navigation.isNavigationReady().then(() => {
if (ignore) {
return;
}
setHasInitiatedSAMLLogin(true);
hasPendingSAMLRedirectForCurrentSignIn = false;
Navigation.navigate(ROUTES.SAML_SIGN_IN);
});
return () => {
ignore = true;
};
}, [shouldInitiateSAMLLogin]);Reviewed at: 1cd1a2b | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
|
@ZhenjaHorbach PR is ready for review: #93528 One edge case I wanted to call out before review: the implementation follows the selected proposal by using a non-persisted pending sign-in/SAML signal keyed from During regression review, I noticed one possible multi-tab case. Since My take is that this is a P2 edge case and outside the core bug fix, but I wanted to ask before review: do you think we should add an explicit active/leader-tab guard for the required-SAML auto-navigation, or keep this implementation proposal-scoped and let QA validate the multi-tab behavior? |
Explanation of Change
This PR makes the required-SAML sign-in redirect resilient to the transient
account.isLoadingvalue fromBeginSignIn.Previously,
SignInPageonly initiated required SAML whenaccount.isLoadingandaccount.isSAMLRequiredwere true in the same render. If the completedBeginSignInresponse setisSAMLRequired: trueafter loading was already cleared, the sign-in page could clear credentials instead of navigating to SAML.This change:
isLoading: false.credentials.loginandshortLivedAuthTokencontinue even ifaccount.isLoadingis true, while guarding duplicate callback consumption locally.Fixed Issues
$ #92479
PROPOSAL: #92479 (comment)
Tests
Additional local frontend-only verification was performed with an Onyx fixture that simulates a completed
BeginSignInresponse withaccount.isSAMLRequired: trueandaccount.isLoading: false.Offline tests
N/A. SAML sign-in requires network access to request the IdP URL and complete authentication. No offline behavior was changed.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
ezyZip.42.mp4
Android: mWeb Chrome
ezyZip.40.mp4
iOS: Native
ezyZip.41.mp4
iOS: mWeb Safari
ios_mwebScreen.Recording.2026-06-13.at.5.16.54.PM.mov
MacOS: Chrome / Safari
ezyZip.39.mp4