Skip to content

Commit 6f18aaa

Browse files
committed
Revert "Fix web SAML cancel not showing login form on browser-back"
This reverts commit 452c858.
1 parent 452c858 commit 6f18aaa

2 files changed

Lines changed: 3 additions & 24 deletions

File tree

src/pages/signin/SAMLSignInPage/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ function SAMLSignInPage() {
2727
handleSAMLLoginError(translate('common.error.login'), false);
2828
return;
2929
}
30-
// Mark that SAML login was initiated so SignInPage can detect a browser-back
31-
// from the IdP and clear sign-in data instead of re-initiating SAML
32-
sessionStorage.setItem('EXPENSIFY_SAML_INITIATED', 'true');
3330
window.location.replace(response.url);
3431
})
3532
.catch((error: Error) => {

src/pages/signin/SignInPage.tsx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ type GetRenderOptionsParams = {
6767
isPrimaryLogin: boolean;
6868
isUsingMagicCode: boolean;
6969
hasInitiatedSAMLLogin: boolean;
70-
isReturningFromSAMLOnWeb: boolean;
7170
shouldShowAnotherLoginPageOpenedMessage: boolean;
7271
credentials: OnyxEntry<Credentials>;
7372
isAccountValidated?: boolean;
@@ -90,7 +89,6 @@ function getRenderOptions({
9089
isPrimaryLogin,
9190
isUsingMagicCode,
9291
hasInitiatedSAMLLogin,
93-
isReturningFromSAMLOnWeb,
9492
shouldShowAnotherLoginPageOpenedMessage,
9593
credentials,
9694
isAccountValidated,
@@ -102,14 +100,13 @@ function getRenderOptions({
102100
const hasSMSDeliveryFailure = !!account?.smsDeliveryFailureStatus?.hasSMSDeliveryFailure;
103101

104102
// True, if the user has SAML required, and we haven't yet initiated SAML for their account
105-
const shouldInitiateSAMLLogin = hasAccount && hasLogin && isSAMLRequired && !hasInitiatedSAMLLogin && !isReturningFromSAMLOnWeb && !!account.isLoading;
103+
const shouldInitiateSAMLLogin = hasAccount && hasLogin && isSAMLRequired && !hasInitiatedSAMLLogin && !!account.isLoading;
106104
const shouldShowChooseSSOOrMagicCode = hasAccount && hasLogin && isSAMLEnabled && !isSAMLRequired && !isUsingMagicCode;
107105

108106
// SAML required users may reload the login page after having already entered their login details, in which
109107
// case we want to clear their sign in data so they don't end up in an infinite loop redirecting back to their
110-
// SSO provider's login page. On web, also trigger when returning from an IdP redirect (browser-back) since
111-
// account.isLoading may still be true during Onyx hydration.
112-
const isClearingSAMLSignInData = hasLogin && isSAMLRequired && !shouldInitiateSAMLLogin && ((!hasInitiatedSAMLLogin && !account.isLoading) || isReturningFromSAMLOnWeb);
108+
// SSO provider's login page
109+
const isClearingSAMLSignInData = hasLogin && isSAMLRequired && !shouldInitiateSAMLLogin && !hasInitiatedSAMLLogin && !account.isLoading;
113110
if (isClearingSAMLSignInData) {
114111
clearSignInData();
115112
}
@@ -180,20 +177,6 @@ function SignInPage({ref}: SignInPageProps) {
180177
* if we need to clear their sign in details so they can enter a login */
181178
const [hasInitiatedSAMLLogin, setHasInitiatedSAMLLogin] = useState(false);
182179

183-
// On web, detect if the user is returning from a SAML IdP redirect (e.g. browser-back).
184-
// sessionStorage survives page reloads within the same tab, unlike React state.
185-
const [isReturningFromSAMLOnWeb] = useState(() => {
186-
if (typeof sessionStorage === 'undefined') {
187-
return false;
188-
}
189-
const flag = sessionStorage.getItem('EXPENSIFY_SAML_INITIATED');
190-
if (flag === 'true') {
191-
sessionStorage.removeItem('EXPENSIFY_SAML_INITIATED');
192-
return true;
193-
}
194-
return false;
195-
});
196-
197180
const isClientTheLeader = !!activeClients && isClientTheLeaderActiveClientManager();
198181
// We need to show "Another login page is opened" message if the page isn't active and visible
199182
// eslint-disable-next-line rulesdir/no-negated-variables
@@ -231,7 +214,6 @@ function SignInPage({ref}: SignInPageProps) {
231214
isPrimaryLogin: !account?.primaryLogin || account.primaryLogin === credentials?.login,
232215
isUsingMagicCode,
233216
hasInitiatedSAMLLogin,
234-
isReturningFromSAMLOnWeb,
235217
shouldShowAnotherLoginPageOpenedMessage,
236218
credentials,
237219
isAccountValidated,

0 commit comments

Comments
 (0)