Skip to content

Commit e460464

Browse files
Merge pull request Expensify#89680 from Expensify/Rory-RestoreRedirectToSignin
[No QA] Restore commented-out SAML redirect to signin code
2 parents ebab91b + fd3aba5 commit e460464

2 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/libs/Reauthentication.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,9 @@ function reauthenticate(command = ''): Promise<boolean> {
140140
// Prevent reauthentication if credentials are missing (e.g. after sign out)
141141
if (!credentials?.autoGeneratedLogin || !credentials?.autoGeneratedPassword) {
142142
Log.info('[Reauthenticate] No credentials available, redirecting to sign in');
143-
// The following lines are commented out to test if it's the cause of #fireroom-2026-01-28-user-signout
144-
// setIsAuthenticating(false);
145-
// redirectToSignIn('No credentials available');
146-
// return false;
143+
setIsAuthenticating(false);
144+
redirectToSignIn('No credentials available');
145+
return false;
147146
}
148147

149148
Log.info(`[Reauthenticate] Re-authenticating with ${shouldUseNewPartnerName ? 'new' : 'old'} partner name`);

tests/actions/SessionTest.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {setHasRadio} from '@libs/NetworkState';
1616
import PushNotification from '@libs/Notification/PushNotification';
1717
// This lib needs to be imported, but it has nothing to export since all it contains is an Onyx connection
1818
import '@libs/Notification/PushNotification/subscribeToPushNotifications';
19+
import reauthenticate from '@libs/Reauthentication';
1920
import CONFIG from '@src/CONFIG';
2021
import CONST from '@src/CONST';
2122
import * as SessionUtil from '@src/libs/actions/Session';
@@ -62,6 +63,22 @@ beforeEach(() => {
6263
});
6364

6465
describe('Session', () => {
66+
test('reauthenticate redirects to sign in with "No credentials available" when credentials are missing', async () => {
67+
// Given no signed-in user — beforeEach calls Onyx.clear(), so NetworkStore's credentials are null
68+
69+
const redirectToSignInSpy = jest.spyOn(SignInRedirect, 'default').mockImplementation(() => Promise.resolve());
70+
71+
// When reauthenticate is called with no credentials stored
72+
const result = await reauthenticate('TestCommand');
73+
await waitForBatchedUpdates();
74+
75+
// Then it should redirect to sign in instead of attempting to call Authenticate with undefined credentials
76+
expect(result).toBe(false);
77+
expect(redirectToSignInSpy).toHaveBeenCalledWith('No credentials available');
78+
79+
redirectToSignInSpy.mockRestore();
80+
});
81+
6582
test('Authenticate is called with saved credentials when a session expires', async () => {
6683
// Given a test user and set of authToken with subscriptions to session and credentials
6784
const TEST_USER_LOGIN = 'test@testguy.com';

0 commit comments

Comments
 (0)