Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(console): surface secure storage login failures

lgoyal67dcf8c21f950
diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.test.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.test.ts
index c77b3f25a..6c151fb6e 100644
--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.test.ts
+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.test.ts
@@ -32,6 +32,7 @@ const {
callbackHostHop,
cancelOidcLogin,
oidcLogin,
+ passwordLogin,
reauthenticateManagedServer,
refreshSession,
signup,
@@ -175,6 +176,24 @@ function response(status: number, body: unknown, cookies: string[] = []): Respon
});
}
+describe('passwordLogin', () => {
+ it('surfaces secure-storage failures after the server accepts the credentials', async () => {
+ fetchMock.mockResolvedValueOnce(response(200, USER, ['switch_auth=SESSION']));
+ setSessionCookie.mockRejectedValueOnce(new Error('Secure secret storage is unavailable.'));
+
+ const result = await passwordLogin(SIGNUP_SERVER, '[email protected]', 'correct-horse');
+
+ expect(result).toEqual({
+ success: false,
+ error: {
+ kind: 'failed',
+ message:
+ 'Login succeeded, but Switch Console could not save the session securely: Secure secret storage is unavailable. Check that the operating system keychain is available, then sign in again.',
+ },
+ });
+ });
+});
+
describe('signup', () => {
beforeEach(() => {
vi.clearAllMocks();
diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.ts
index 389f018e2..ba0860398 100644
--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.ts
+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/auth.ts
@@ -138,7 +138,15 @@ async function persistSessionCookie(
message: `${action} succeeded but the gateway did not return a session cookie.`,
});
}
- await setSessionCookie(server.id, jwt);
+ try {
+ await setSessionCookie(server.id, jwt);
+ } catch (cause) {
+ const detail = cause instanceof Error ? `: ${cause.message}` : '';
+ return err({
+ kind: 'failed',
+ message: `${action} succeeded, but Switch Console could not save the session securely${detail}${detail ? '' : '.'} Check that the operating system keychain is available, then sign in again.`,
+ });
+ }
return ok(true);
}