fix: ensure fresh Steam login on Add by killing process and clearing auto-login state

This commit is contained in:
2026-02-21 03:11:56 +01:00
parent d68f0a2740
commit 2719bd527a

View File

@@ -506,9 +506,18 @@ ipcMain.handle('switch-account', async (event, loginName: string) => await handl
ipcMain.handle('open-external', (event, url: string) => shell.openExternal(url));
ipcMain.handle('open-steam-app-login', async () => {
console.log('[SteamClient] Triggering desktop login window...');
// Force Steam to show login window.
// steam://open/login is the protocol for this.
console.log('[SteamClient] Preparing for fresh login...');
await killSteam();
if (process.platform === 'win32') {
// Clear auto-login registry
const clearReg = 'reg add "HKCU\\Software\\Valve\\Steam" /v AutoLoginUser /t REG_SZ /d "" /f';
await new Promise<void>((res) => exec(clearReg, () => res()));
} else if (process.platform === 'linux') {
// On Linux we can use the steamClient helper to set an empty user
await steamClient.setAutoLoginUser("", undefined, "");
}
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
exec(command);
return true;