feat: implement granular access revocation and global unsharing in the account permissions dialog
This commit is contained in:
@@ -488,6 +488,18 @@ ipcMain.handle('share-account-with-user', async (event, steamId: string, targetS
|
||||
throw new Error('Backend not configured');
|
||||
});
|
||||
|
||||
ipcMain.handle('revoke-account-access', async (event, steamId: string, targetSteamId: string) => {
|
||||
initBackend();
|
||||
if (backend) return await backend.revokeAccess(steamId, targetSteamId);
|
||||
throw new Error('Backend not configured');
|
||||
});
|
||||
|
||||
ipcMain.handle('revoke-all-account-access', async (event, steamId: string) => {
|
||||
initBackend();
|
||||
if (backend) return await backend.revokeAllAccess(steamId);
|
||||
throw new Error('Backend not configured');
|
||||
});
|
||||
|
||||
ipcMain.handle('get-community-accounts', async () => { initBackend(); return backend ? await backend.getCommunityAccounts() : []; });
|
||||
ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
|
||||
ipcMain.handle('switch-account', async (event, loginName: string) => await handleSwitchAccount(loginName));
|
||||
|
||||
@@ -7,6 +7,8 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
deleteAccount: (id: string) => ipcRenderer.invoke('delete-account', id),
|
||||
switchAccount: (loginName: string) => ipcRenderer.invoke('switch-account', loginName),
|
||||
shareAccountWithUser: (steamId: string, targetSteamId: string) => ipcRenderer.invoke('share-account-with-user', steamId, targetSteamId),
|
||||
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),
|
||||
openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId),
|
||||
|
||||
|
||||
@@ -61,7 +61,8 @@ export class BackendService {
|
||||
gameBans: account.gameBans,
|
||||
loginName: account.loginName,
|
||||
steamLoginSecure: account.steamLoginSecure,
|
||||
loginConfig: account.loginConfig
|
||||
loginConfig: account.loginConfig,
|
||||
sessionUpdatedAt: account.sessionUpdatedAt
|
||||
}, { headers: this.headers });
|
||||
} catch (e) {
|
||||
console.error('[Backend] Failed to share account');
|
||||
@@ -91,4 +92,31 @@ export class BackendService {
|
||||
throw new Error(e.response?.data?.message || 'Failed to share account');
|
||||
}
|
||||
}
|
||||
|
||||
public async revokeAccess(steamId: string, targetSteamId: string) {
|
||||
if (!this.token) return;
|
||||
try {
|
||||
const response = await axios.delete(`${this.url}/api/sync/${steamId}/share`, {
|
||||
headers: this.headers,
|
||||
data: { targetSteamId }
|
||||
});
|
||||
return response.data;
|
||||
} catch (e: any) {
|
||||
console.error(`[Backend] Failed to revoke access for ${steamId} from ${targetSteamId}`);
|
||||
throw new Error(e.response?.data?.message || 'Failed to revoke access');
|
||||
}
|
||||
}
|
||||
|
||||
public async revokeAllAccess(steamId: string) {
|
||||
if (!this.token) return;
|
||||
try {
|
||||
const response = await axios.delete(`${this.url}/api/sync/${steamId}/share/all`, {
|
||||
headers: this.headers
|
||||
});
|
||||
return response.data;
|
||||
} catch (e: any) {
|
||||
console.error(`[Backend] Failed to revoke all access for ${steamId}`);
|
||||
throw new Error(e.response?.data?.message || 'Failed to revoke all access');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user