diff --git a/frontend/electron/main.ts b/frontend/electron/main.ts index ec1df1c..fed6c7f 100644 --- a/frontend/electron/main.ts +++ b/frontend/electron/main.ts @@ -524,13 +524,40 @@ ipcMain.handle('open-steam-app-login', async () => { }); ipcMain.handle('open-steam-login', async (event, expectedSteamId: string) => { - const loginSession = session.fromPartition('persist:steam-login'); - // Removed: automatic clearStorageData to allow cookie persistence + // Use a unique partition per account to prevent session bleeding + const partitionId = expectedSteamId ? `persist:steam-login-${expectedSteamId}` : 'persist:steam-login-new'; + const loginSession = session.fromPartition(partitionId); + + // If we have an existing cookie string for this account, pre-inject it + if (expectedSteamId) { + const accounts = store.get('accounts') as Account[]; + const account = accounts.find(a => a.steamId === expectedSteamId); + if (account?.steamLoginSecure) { + console.log(`[Auth] Pre-injecting existing cookies for ${account.personaName}...`); + const cookiePairs = account.steamLoginSecure.split(';').map(c => c.trim()); + for (const pair of cookiePairs) { + const [name, value] = pair.split('='); + if (name && value) { + try { + await loginSession.cookies.set({ + url: 'https://steamcommunity.com', + domain: 'steamcommunity.com', + name: name, + value: value, + path: '/', + secure: true, + httpOnly: name.includes('Secure') + }); + } catch (e) {} + } + } + } + } return new Promise((resolve) => { const loginWindow = new BrowserWindow({ width: 800, height: 700, parent: mainWindow || undefined, modal: true, title: 'Login to Steam', - webPreferences: { nodeIntegration: false, contextIsolation: true, partition: 'persist:steam-login' } + webPreferences: { nodeIntegration: false, contextIsolation: true, partition: partitionId } }); loginWindow.loadURL('https://steamcommunity.com/login/home/?goto=my/gcpd/730'); const checkCookie = setInterval(async () => {