feat: trigger actual Steam desktop login window via protocol handler for native account addition

This commit is contained in:
2026-02-21 03:04:56 +01:00
parent e16a537621
commit d68f0a2740
6 changed files with 27 additions and 3 deletions

View File

@@ -518,6 +518,14 @@ electron_1.ipcMain.handle('get-community-accounts', async () => { initBackend();
electron_1.ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; }); electron_1.ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
electron_1.ipcMain.handle('switch-account', async (event, loginName) => await handleSwitchAccount(loginName)); electron_1.ipcMain.handle('switch-account', async (event, loginName) => await handleSwitchAccount(loginName));
electron_1.ipcMain.handle('open-external', (event, url) => electron_1.shell.openExternal(url)); electron_1.ipcMain.handle('open-external', (event, url) => electron_1.shell.openExternal(url));
electron_1.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.
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
(0, child_process_1.exec)(command);
return true;
});
electron_1.ipcMain.handle('open-steam-login', async (event, expectedSteamId) => { electron_1.ipcMain.handle('open-steam-login', async (event, expectedSteamId) => {
const loginSession = electron_1.session.fromPartition('persist:steam-login'); const loginSession = electron_1.session.fromPartition('persist:steam-login');
// Removed: automatic clearStorageData to allow cookie persistence // Removed: automatic clearStorageData to allow cookie persistence

View File

@@ -11,6 +11,7 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
revokeAccountAccess: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId), revokeAccountAccess: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId),
revokeAllAccountAccess: (steamId) => electron_1.ipcRenderer.invoke('revoke-all-account-access', steamId), revokeAllAccountAccess: (steamId) => electron_1.ipcRenderer.invoke('revoke-all-account-access', steamId),
openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url), openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url),
openSteamAppLogin: () => electron_1.ipcRenderer.invoke('open-steam-app-login'),
openSteamLogin: (steamId) => electron_1.ipcRenderer.invoke('open-steam-login', steamId), openSteamLogin: (steamId) => electron_1.ipcRenderer.invoke('open-steam-login', steamId),
// Server Config & Auth // Server Config & Auth
getServerConfig: () => electron_1.ipcRenderer.invoke('get-server-config'), getServerConfig: () => electron_1.ipcRenderer.invoke('get-server-config'),

View File

@@ -505,6 +505,15 @@ ipcMain.handle('get-server-users', async () => { initBackend(); return backend ?
ipcMain.handle('switch-account', async (event, loginName: string) => await handleSwitchAccount(loginName)); ipcMain.handle('switch-account', async (event, loginName: string) => await handleSwitchAccount(loginName));
ipcMain.handle('open-external', (event, url: string) => shell.openExternal(url)); 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.
const command = process.platform === 'win32' ? 'start steam://open/login' : 'xdg-open steam://open/login';
exec(command);
return true;
});
ipcMain.handle('open-steam-login', async (event, expectedSteamId: string) => { ipcMain.handle('open-steam-login', async (event, expectedSteamId: string) => {
const loginSession = session.fromPartition('persist:steam-login'); const loginSession = session.fromPartition('persist:steam-login');
// Removed: automatic clearStorageData to allow cookie persistence // Removed: automatic clearStorageData to allow cookie persistence

View File

@@ -10,6 +10,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
revokeAccountAccess: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId), revokeAccountAccess: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId),
revokeAllAccountAccess: (steamId: string) => ipcRenderer.invoke('revoke-all-account-access', steamId), revokeAllAccountAccess: (steamId: string) => ipcRenderer.invoke('revoke-all-account-access', steamId),
openExternal: (url: string) => ipcRenderer.invoke('open-external', url), openExternal: (url: string) => ipcRenderer.invoke('open-external', url),
openSteamAppLogin: () => ipcRenderer.invoke('open-steam-app-login'),
openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId), openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId),
// Server Config & Auth // Server Config & Auth

View File

@@ -38,6 +38,7 @@ interface AccountsContextType {
updateAccount: (id: string, data: Partial<Account>) => Promise<void>; updateAccount: (id: string, data: Partial<Account>) => Promise<void>;
deleteAccount: (id: string) => Promise<void>; deleteAccount: (id: string) => Promise<void>;
switchAccount: (loginName: string) => Promise<void>; switchAccount: (loginName: string) => Promise<void>;
openSteamAppLogin: () => Promise<void>;
openSteamLogin: (steamId: string) => Promise<void>; openSteamLogin: (steamId: string) => Promise<void>;
shareAccountWithUser: (steamId: string, targetSteamId: string) => Promise<any>; shareAccountWithUser: (steamId: string, targetSteamId: string) => Promise<any>;
revokeAccountAccess: (steamId: string, targetSteamId: string) => Promise<any>; revokeAccountAccess: (steamId: string, targetSteamId: string) => Promise<any>;
@@ -127,6 +128,10 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
await (window as any).electronAPI.switchAccount(loginName); await (window as any).electronAPI.switchAccount(loginName);
}; };
const openSteamAppLogin = async () => {
await (window as any).electronAPI.openSteamAppLogin();
};
const openSteamLogin = async (steamId: string) => { const openSteamLogin = async (steamId: string) => {
await (window as any).electronAPI.openSteamLogin(steamId); await (window as any).electronAPI.openSteamLogin(steamId);
await syncNow(); await syncNow();
@@ -172,7 +177,7 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
return ( return (
<AccountsContext.Provider value={{ <AccountsContext.Provider value={{
accounts, serverConfig, isLoading, isSyncing, addAccount, updateAccount, deleteAccount, accounts, serverConfig, isLoading, isSyncing, addAccount, updateAccount, deleteAccount,
switchAccount, openSteamLogin, updateServerConfig, loginToServer, switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer,
getCommunityAccounts, getServerUsers, shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, syncNow, refreshAccounts getCommunityAccounts, getServerUsers, shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, syncNow, refreshAccounts
}}> }}>
{children} {children}

View File

@@ -34,7 +34,7 @@ const Dashboard: React.FC = () => {
const { currentTheme, setTheme } = useAppTheme(); const { currentTheme, setTheme } = useAppTheme();
const { const {
accounts, isLoading, isSyncing, serverConfig, deleteAccount, accounts, isLoading, isSyncing, serverConfig, deleteAccount,
switchAccount, openSteamLogin, updateServerConfig, loginToServer, syncNow switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer, syncNow
} = useAccounts(); } = useAccounts();
const [searchTerm, setSearchTerm] = useState(''); const [searchTerm, setSearchTerm] = useState('');
@@ -104,7 +104,7 @@ const Dashboard: React.FC = () => {
variant="contained" variant="contained"
color="primary" color="primary"
startIcon={<AddIcon />} startIcon={<AddIcon />}
onClick={() => openSteamLogin('')} onClick={() => openSteamAppLogin()}
sx={{ height: 32 }} sx={{ height: 32 }}
> >
Add Add