Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/libs/Reauthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,9 @@ function reauthenticate(command = ''): Promise<boolean> {
// Prevent reauthentication if credentials are missing (e.g. after sign out)
if (!credentials?.autoGeneratedLogin || !credentials?.autoGeneratedPassword) {
Log.info('[Reauthenticate] No credentials available, redirecting to sign in');
// The following lines are commented out to test if it's the cause of #fireroom-2026-01-28-user-signout
// setIsAuthenticating(false);
// redirectToSignIn('No credentials available');
// return false;
setIsAuthenticating(false);
redirectToSignIn('No credentials available');
return false;
}

Log.info(`[Reauthenticate] Re-authenticating with ${shouldUseNewPartnerName ? 'new' : 'old'} partner name`);
Expand Down
17 changes: 17 additions & 0 deletions tests/actions/SessionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {setHasRadio} from '@libs/NetworkState';
import PushNotification from '@libs/Notification/PushNotification';
// This lib needs to be imported, but it has nothing to export since all it contains is an Onyx connection
import '@libs/Notification/PushNotification/subscribeToPushNotifications';
import reauthenticate from '@libs/Reauthentication';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
import * as SessionUtil from '@src/libs/actions/Session';
Expand Down Expand Up @@ -62,6 +63,22 @@ beforeEach(() => {
});

describe('Session', () => {
test('reauthenticate redirects to sign in with "No credentials available" when credentials are missing', async () => {
// Given no signed-in user — beforeEach calls Onyx.clear(), so NetworkStore's credentials are null

const redirectToSignInSpy = jest.spyOn(SignInRedirect, 'default').mockImplementation(() => Promise.resolve());

// When reauthenticate is called with no credentials stored
const result = await reauthenticate('TestCommand');
await waitForBatchedUpdates();

// Then it should redirect to sign in instead of attempting to call Authenticate with undefined credentials
expect(result).toBe(false);
expect(redirectToSignInSpy).toHaveBeenCalledWith('No credentials available');

redirectToSignInSpy.mockRestore();
});

test('Authenticate is called with saved credentials when a session expires', async () => {
// Given a test user and set of authToken with subscriptions to session and credentials
const TEST_USER_LOGIN = 'test@testguy.com';
Expand Down
Loading