feat: trigger actual Steam desktop login window via protocol handler for native account addition
This commit is contained in:
@@ -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('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-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) => {
|
||||
const loginSession = electron_1.session.fromPartition('persist:steam-login');
|
||||
// Removed: automatic clearStorageData to allow cookie persistence
|
||||
|
||||
@@ -11,6 +11,7 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
|
||||
revokeAccountAccess: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId),
|
||||
revokeAllAccountAccess: (steamId) => electron_1.ipcRenderer.invoke('revoke-all-account-access', steamId),
|
||||
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),
|
||||
// Server Config & Auth
|
||||
getServerConfig: () => electron_1.ipcRenderer.invoke('get-server-config'),
|
||||
|
||||
@@ -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('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) => {
|
||||
const loginSession = session.fromPartition('persist:steam-login');
|
||||
// Removed: automatic clearStorageData to allow cookie persistence
|
||||
|
||||
@@ -10,6 +10,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
revokeAccountAccess: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId),
|
||||
revokeAllAccountAccess: (steamId: string) => ipcRenderer.invoke('revoke-all-account-access', steamId),
|
||||
openExternal: (url: string) => ipcRenderer.invoke('open-external', url),
|
||||
openSteamAppLogin: () => ipcRenderer.invoke('open-steam-app-login'),
|
||||
openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId),
|
||||
|
||||
// Server Config & Auth
|
||||
|
||||
@@ -38,6 +38,7 @@ interface AccountsContextType {
|
||||
updateAccount: (id: string, data: Partial<Account>) => Promise<void>;
|
||||
deleteAccount: (id: string) => Promise<void>;
|
||||
switchAccount: (loginName: string) => Promise<void>;
|
||||
openSteamAppLogin: () => Promise<void>;
|
||||
openSteamLogin: (steamId: string) => Promise<void>;
|
||||
shareAccountWithUser: (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);
|
||||
};
|
||||
|
||||
const openSteamAppLogin = async () => {
|
||||
await (window as any).electronAPI.openSteamAppLogin();
|
||||
};
|
||||
|
||||
const openSteamLogin = async (steamId: string) => {
|
||||
await (window as any).electronAPI.openSteamLogin(steamId);
|
||||
await syncNow();
|
||||
@@ -172,7 +177,7 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
|
||||
return (
|
||||
<AccountsContext.Provider value={{
|
||||
accounts, serverConfig, isLoading, isSyncing, addAccount, updateAccount, deleteAccount,
|
||||
switchAccount, openSteamLogin, updateServerConfig, loginToServer,
|
||||
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer,
|
||||
getCommunityAccounts, getServerUsers, shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, syncNow, refreshAccounts
|
||||
}}>
|
||||
{children}
|
||||
|
||||
@@ -34,7 +34,7 @@ const Dashboard: React.FC = () => {
|
||||
const { currentTheme, setTheme } = useAppTheme();
|
||||
const {
|
||||
accounts, isLoading, isSyncing, serverConfig, deleteAccount,
|
||||
switchAccount, openSteamLogin, updateServerConfig, loginToServer, syncNow
|
||||
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer, syncNow
|
||||
} = useAccounts();
|
||||
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
@@ -104,7 +104,7 @@ const Dashboard: React.FC = () => {
|
||||
variant="contained"
|
||||
color="primary"
|
||||
startIcon={<AddIcon />}
|
||||
onClick={() => openSteamLogin('')}
|
||||
onClick={() => openSteamAppLogin()}
|
||||
sx={{ height: 32 }}
|
||||
>
|
||||
Add
|
||||
|
||||
Reference in New Issue
Block a user