18 Commits

Author SHA1 Message Date
589acdebcb Merge pull request 'chore: bump version to 1.3.0' (#7) from release/v1.3.0 into main
All checks were successful
Build and Release / build (push) Successful in 5m39s
Reviewed-on: #7
2026-02-21 03:37:38 +01:00
cf78e3c329 chore: bump version to 1.3.0 2026-02-21 03:37:46 +01:00
4037d7bce3 Merge pull request 'chore: update application title in index.html from frontend to Ultimate Ban Tracker' (#6) from release/v1.3.0 into main
Some checks failed
Build and Release / build (push) Has been cancelled
Reviewed-on: #6
2026-02-21 03:36:37 +01:00
fc3382c91e chore: update application title in index.html from frontend to Ultimate Ban Tracker 2026-02-21 03:36:21 +01:00
5d611fd8be Merge pull request 'feat: implement comprehensive admin dashboard for server management and user oversight' (#5) from release/v1.3.0 into main
Some checks failed
Build and Release / build (push) Has been cancelled
Reviewed-on: #5
2026-02-21 03:35:22 +01:00
ee44de182c fix: implement robust multi-phase synchronization and server-side reconciliation 2026-02-21 03:34:31 +01:00
6dc940bb3a feat: implement comprehensive admin dashboard for server management and user oversight 2026-02-21 03:28:21 +01:00
fa29bd5a85 chore: bump version to 1.2.0 and commit recent fixes/features including tray and auth isolation 2026-02-21 03:21:55 +01:00
88d2a2133c Merge pull request 'chore: bump version to 1.2.0 and commit recent fixes/features including tray and auth isolation' (#4) from release/v1.2.0 into main
All checks were successful
Build and Release / build (push) Successful in 5m37s
Reviewed-on: #4
2026-02-21 03:21:45 +01:00
5812888bb7 Merge pull request 'feat/revoke-share' (#3) from feat/revoke-share into main
Some checks failed
Build and Release / build (push) Has been cancelled
Reviewed-on: #3
2026-02-21 03:19:34 +01:00
9d5f77dc09 fix: explicitly clear storage for new account logins to prevent session leakage 2026-02-21 03:19:00 +01:00
75accbe5b6 fix: implement per-account session isolation and cookie injection for robust authentication 2026-02-21 03:17:38 +01:00
2719bd527a fix: ensure fresh Steam login on Add by killing process and clearing auto-login state 2026-02-21 03:11:56 +01:00
d68f0a2740 feat: trigger actual Steam desktop login window via protocol handler for native account addition 2026-02-21 03:04:56 +01:00
e16a537621 fix: resolve JSX syntax error by correctly closing the Dashboard component 2026-02-21 03:02:46 +01:00
6f66f33a9b feat: implement primary account identifier and streamline add account flow via direct Steam login 2026-02-21 03:01:33 +01:00
f0740997d0 fix: refine community icon logic to only show when an account is actively shared with others 2026-02-21 02:56:45 +01:00
1f5d2e08e5 feat: implement granular access revocation and global unsharing in the account permissions dialog 2026-02-21 02:45:01 +01:00
12 changed files with 836 additions and 237 deletions

View File

@@ -214,6 +214,12 @@ const syncAccounts = async () => {
for (const account of updatedAccounts) {
try {
const now = new Date();
// OPTIMIZATION: Ensure ALL authenticated accounts are shared with the server on every sync cycle
// this guarantees that even if a push failed previously, it will be reconciled now.
if (backend && !account._id.startsWith('shared_')) {
console.log(`[Sync] Reconciling account with server: ${account.personaName}`);
await backend.shareAccount(account);
}
const lastCheck = account.lastBanCheck ? new Date(account.lastBanCheck) : new Date(0);
if ((now.getTime() - lastCheck.getTime()) / 3600000 > 6 || !account.personaName) {
const profile = await (0, steam_web_1.fetchProfileData)(account.steamId, account.steamLoginSecure);
@@ -401,13 +407,15 @@ electron_1.ipcMain.handle('login-to-server', async () => {
return;
captured = true;
let serverSteamId = undefined;
let isAdmin = false;
try {
const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
serverSteamId = payload.steamId;
isAdmin = !!payload.isAdmin;
}
catch (e) { }
const current = store.get('serverConfig');
store.set('serverConfig', { ...current, token, serverSteamId, enabled: true });
store.set('serverConfig', { ...current, token, serverSteamId, isAdmin, enabled: true });
initBackend();
authWindow.close();
resolve(true);
@@ -502,17 +510,85 @@ electron_1.ipcMain.handle('share-account-with-user', async (event, steamId, targ
}
throw new Error('Backend not configured');
});
electron_1.ipcMain.handle('revoke-account-access', async (event, steamId, targetSteamId) => {
initBackend();
if (backend)
return await backend.revokeAccess(steamId, targetSteamId);
throw new Error('Backend not configured');
});
electron_1.ipcMain.handle('revoke-all-account-access', async (event, steamId) => {
initBackend();
if (backend)
return await backend.revokeAllAccess(steamId);
throw new Error('Backend not configured');
});
electron_1.ipcMain.handle('get-community-accounts', async () => { initBackend(); return backend ? await backend.getCommunityAccounts() : []; });
electron_1.ipcMain.handle('get-server-users', async () => { initBackend(); return backend ? await backend.getServerUsers() : []; });
// --- Admin IPC ---
electron_1.ipcMain.handle('admin-get-stats', async () => { initBackend(); return backend ? await backend.getAdminStats() : null; });
electron_1.ipcMain.handle('admin-get-users', async () => { initBackend(); return backend ? await backend.getAdminUsers() : []; });
electron_1.ipcMain.handle('admin-delete-user', async (event, userId) => { initBackend(); if (backend)
await backend.deleteUser(userId); return true; });
electron_1.ipcMain.handle('admin-get-accounts', async () => { initBackend(); return backend ? await backend.getAdminAccounts() : []; });
electron_1.ipcMain.handle('admin-remove-account', async (event, steamId) => { initBackend(); if (backend)
await backend.forceRemoveAccount(steamId); return true; });
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] 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((res) => (0, child_process_1.exec)(clearReg, () => res()));
}
else if (process.platform === 'linux') {
// On Linux we can use the steamClient helper to set an empty user
await steam_client_1.steamClient.setAutoLoginUser("", undefined, "");
}
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
// Use a unique partition per account to prevent session bleeding
const partitionId = expectedSteamId ? `persist:steam-login-${expectedSteamId}` : 'persist:steam-login-new';
const loginSession = electron_1.session.fromPartition(partitionId);
// If adding a brand new account, explicitly clear previous trash
if (!expectedSteamId) {
console.log('[Auth] Clearing session for new account login...');
await loginSession.clearStorageData({ storages: ['cookies', 'localstorage', 'indexdb'] });
}
// If we have an existing cookie string for this account, pre-inject it
if (expectedSteamId) {
const accounts = store.get('accounts');
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 electron_1.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 () => {

View File

@@ -8,7 +8,10 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
deleteAccount: (id) => electron_1.ipcRenderer.invoke('delete-account', id),
switchAccount: (loginName) => electron_1.ipcRenderer.invoke('switch-account', loginName),
shareAccountWithUser: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('share-account-with-user', 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),
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'),
@@ -18,6 +21,12 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', {
syncNow: () => electron_1.ipcRenderer.invoke('sync-now'),
getCommunityAccounts: () => electron_1.ipcRenderer.invoke('get-community-accounts'),
getServerUsers: () => electron_1.ipcRenderer.invoke('get-server-users'),
// Admin API
adminGetStats: () => electron_1.ipcRenderer.invoke('admin-get-stats'),
adminGetUsers: () => electron_1.ipcRenderer.invoke('admin-get-users'),
adminDeleteUser: (userId) => electron_1.ipcRenderer.invoke('admin-delete-user', userId),
adminGetAccounts: () => electron_1.ipcRenderer.invoke('admin-get-accounts'),
adminRemoveAccount: (steamId) => electron_1.ipcRenderer.invoke('admin-remove-account', steamId),
onAccountsUpdated: (callback) => {
const subscription = (_event, accounts) => callback(accounts);
electron_1.ipcRenderer.on('accounts-updated', subscription);

View File

@@ -67,7 +67,8 @@ 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) {
@@ -100,5 +101,88 @@ class BackendService {
throw new Error(e.response?.data?.message || 'Failed to share account');
}
}
async revokeAccess(steamId, targetSteamId) {
if (!this.token)
return;
try {
const response = await axios_1.default.delete(`${this.url}/api/sync/${steamId}/share`, {
headers: this.headers,
data: { targetSteamId }
});
return response.data;
}
catch (e) {
console.error(`[Backend] Failed to revoke access for ${steamId} from ${targetSteamId}`);
throw new Error(e.response?.data?.message || 'Failed to revoke access');
}
}
async revokeAllAccess(steamId) {
if (!this.token)
return;
try {
const response = await axios_1.default.delete(`${this.url}/api/sync/${steamId}/share/all`, {
headers: this.headers
});
return response.data;
}
catch (e) {
console.error(`[Backend] Failed to revoke all access for ${steamId}`);
throw new Error(e.response?.data?.message || 'Failed to revoke all access');
}
}
// --- Admin API ---
async getAdminStats() {
if (!this.token)
return null;
try {
const response = await axios_1.default.get(`${this.url}/api/admin/stats`, { headers: this.headers });
return response.data;
}
catch (e) {
return null;
}
}
async getAdminUsers() {
if (!this.token)
return [];
try {
const response = await axios_1.default.get(`${this.url}/api/admin/users`, { headers: this.headers });
return response.data;
}
catch (e) {
return [];
}
}
async deleteUser(userId) {
if (!this.token)
return;
try {
await axios_1.default.delete(`${this.url}/api/admin/users/${userId}`, { headers: this.headers });
}
catch (e) {
throw new Error(e.response?.data?.message || 'Failed to delete user');
}
}
async getAdminAccounts() {
if (!this.token)
return [];
try {
const response = await axios_1.default.get(`${this.url}/api/admin/accounts`, { headers: this.headers });
return response.data;
}
catch (e) {
return [];
}
}
async forceRemoveAccount(steamId) {
if (!this.token)
return;
try {
await axios_1.default.delete(`${this.url}/api/admin/accounts/${steamId}`, { headers: this.headers });
}
catch (e) {
throw new Error(e.response?.data?.message || 'Failed to remove account');
}
}
}
exports.BackendService = BackendService;

View File

@@ -242,6 +242,14 @@ const syncAccounts = async () => {
for (const account of updatedAccounts) {
try {
const now = new Date();
// OPTIMIZATION: Ensure ALL authenticated accounts are shared with the server on every sync cycle
// this guarantees that even if a push failed previously, it will be reconciled now.
if (backend && !account._id.startsWith('shared_')) {
console.log(`[Sync] Reconciling account with server: ${account.personaName}`);
await backend.shareAccount(account);
}
const lastCheck = account.lastBanCheck ? new Date(account.lastBanCheck) : new Date(0);
if ((now.getTime() - lastCheck.getTime()) / 3600000 > 6 || !account.personaName) {
const profile = await fetchProfileData(account.steamId, account.steamLoginSecure);
@@ -401,9 +409,14 @@ ipcMain.handle('login-to-server', async () => {
const saveServerAuth = (token: string) => {
if (captured) return; captured = true;
let serverSteamId = undefined;
try { const payload = JSON.parse(Buffer.from(token.split('.')[1]!, 'base64').toString()); serverSteamId = payload.steamId; } catch (e) {}
let isAdmin = false;
try {
const payload = JSON.parse(Buffer.from(token.split('.')[1]!, 'base64').toString());
serverSteamId = payload.steamId;
isAdmin = !!payload.isAdmin;
} catch (e) {}
const current = store.get('serverConfig');
store.set('serverConfig', { ...current, token, serverSteamId, enabled: true });
store.set('serverConfig', { ...current, token, serverSteamId, isAdmin, enabled: true });
initBackend();
authWindow.close();
resolve(true);
@@ -488,19 +501,90 @@ 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() : []; });
// --- Admin IPC ---
ipcMain.handle('admin-get-stats', async () => { initBackend(); return backend ? await backend.getAdminStats() : null; });
ipcMain.handle('admin-get-users', async () => { initBackend(); return backend ? await backend.getAdminUsers() : []; });
ipcMain.handle('admin-delete-user', async (event, userId: string) => { initBackend(); if (backend) await backend.deleteUser(userId); return true; });
ipcMain.handle('admin-get-accounts', async () => { initBackend(); return backend ? await backend.getAdminAccounts() : []; });
ipcMain.handle('admin-remove-account', async (event, steamId: string) => { initBackend(); if (backend) await backend.forceRemoveAccount(steamId); return true; });
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] 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;
});
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 adding a brand new account, explicitly clear previous trash
if (!expectedSteamId) {
console.log('[Auth] Clearing session for new account login...');
await loginSession.clearStorageData({ storages: ['cookies', 'localstorage', 'indexdb'] });
}
// 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<boolean>((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 () => {

View File

@@ -7,7 +7,10 @@ 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),
openSteamAppLogin: () => ipcRenderer.invoke('open-steam-app-login'),
openSteamLogin: (steamId: string) => ipcRenderer.invoke('open-steam-login', steamId),
// Server Config & Auth
@@ -19,6 +22,13 @@ contextBridge.exposeInMainWorld('electronAPI', {
getCommunityAccounts: () => ipcRenderer.invoke('get-community-accounts'),
getServerUsers: () => ipcRenderer.invoke('get-server-users'),
// Admin API
adminGetStats: () => ipcRenderer.invoke('admin-get-stats'),
adminGetUsers: () => ipcRenderer.invoke('admin-get-users'),
adminDeleteUser: (userId: string) => ipcRenderer.invoke('admin-delete-user', userId),
adminGetAccounts: () => ipcRenderer.invoke('admin-get-accounts'),
adminRemoveAccount: (steamId: string) => ipcRenderer.invoke('admin-remove-account', steamId),
onAccountsUpdated: (callback: (accounts: any[]) => void) => {
const subscription = (_event: IpcRendererEvent, accounts: any[]) => callback(accounts);
ipcRenderer.on('accounts-updated', subscription);

View File

@@ -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,75 @@ 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');
}
}
// --- Admin API ---
public async getAdminStats() {
if (!this.token) return null;
try {
const response = await axios.get(`${this.url}/api/admin/stats`, { headers: this.headers });
return response.data;
} catch (e) { return null; }
}
public async getAdminUsers() {
if (!this.token) return [];
try {
const response = await axios.get(`${this.url}/api/admin/users`, { headers: this.headers });
return response.data;
} catch (e) { return []; }
}
public async deleteUser(userId: string) {
if (!this.token) return;
try {
await axios.delete(`${this.url}/api/admin/users/${userId}`, { headers: this.headers });
} catch (e: any) {
throw new Error(e.response?.data?.message || 'Failed to delete user');
}
}
public async getAdminAccounts() {
if (!this.token) return [];
try {
const response = await axios.get(`${this.url}/api/admin/accounts`, { headers: this.headers });
return response.data;
} catch (e) { return []; }
}
public async forceRemoveAccount(steamId: string) {
if (!this.token) return;
try {
await axios.delete(`${this.url}/api/admin/accounts/${steamId}`, { headers: this.headers });
} catch (e: any) {
throw new Error(e.response?.data?.message || 'Failed to remove account');
}
}
}

View File

@@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>frontend</title>
<title>Ultimate Ban Tracker</title>
</head>
<body>
<div id="root"></div>

View File

@@ -1,12 +1,12 @@
{
"name": "ultimate-ban-tracker-desktop",
"version": "1.0.0",
"version": "1.3.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ultimate-ban-tracker-desktop",
"version": "1.0.0",
"version": "1.3.0",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@emotion/react": "^11.14.0",

View File

@@ -1,7 +1,7 @@
{
"name": "ultimate-ban-tracker-desktop",
"description": "Professional Steam Account Manager & Ban Tracker",
"version": "1.1.0",
"version": "1.3.0",
"author": "Nils Pukropp <nils@narl.io>",
"homepage": "https://narl.io",
"license": "SEE LICENSE IN LICENSE",

View File

@@ -27,6 +27,7 @@ export interface ServerConfig {
token?: string;
serverSteamId?: string;
enabled: boolean;
isAdmin?: boolean;
}
interface AccountsContextType {
@@ -38,8 +39,11 @@ 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>;
revokeAllAccountAccess: (steamId: string) => Promise<any>;
// Server Methods
updateServerConfig: (config: Partial<ServerConfig>) => Promise<void>;
@@ -48,6 +52,13 @@ interface AccountsContextType {
getCommunityAccounts: () => Promise<any[]>;
getServerUsers: () => Promise<any[]>;
refreshAccounts: (showLoading?: boolean) => Promise<void>;
// Admin Methods
adminGetStats: () => Promise<any>;
adminGetUsers: () => Promise<any[]>;
adminDeleteUser: (userId: string) => Promise<void>;
adminGetAccounts: () => Promise<any[]>;
adminRemoveAccount: (steamId: string) => Promise<void>;
}
const AccountsContext = createContext<AccountsContextType | undefined>(undefined);
@@ -125,6 +136,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();
@@ -136,6 +151,18 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
return res;
};
const revokeAccountAccess = async (steamId: string, targetSteamId: string) => {
const res = await (window as any).electronAPI.revokeAccountAccess(steamId, targetSteamId);
await syncNow();
return res;
};
const revokeAllAccountAccess = async (steamId: string) => {
const res = await (window as any).electronAPI.revokeAllAccountAccess(steamId);
await syncNow();
return res;
};
const updateServerConfig = async (config: Partial<ServerConfig>) => {
const updated = await (window as any).electronAPI.updateServerConfig(config);
setServerConfig(updated);
@@ -155,11 +182,19 @@ export const AccountsProvider: React.FC<{ children: React.ReactNode }> = ({ chil
return await (window as any).electronAPI.getServerUsers();
};
// --- Admin Methods ---
const adminGetStats = async () => (window as any).electronAPI.adminGetStats();
const adminGetUsers = async () => (window as any).electronAPI.adminGetUsers();
const adminDeleteUser = async (userId: string) => (window as any).electronAPI.adminDeleteUser(userId);
const adminGetAccounts = async () => (window as any).electronAPI.adminGetAccounts();
const adminRemoveAccount = async (steamId: string) => (window as any).electronAPI.adminRemoveAccount(steamId);
return (
<AccountsContext.Provider value={{
accounts, serverConfig, isLoading, isSyncing, addAccount, updateAccount, deleteAccount,
switchAccount, openSteamLogin, updateServerConfig, loginToServer,
getCommunityAccounts, getServerUsers, shareAccountWithUser, syncNow, refreshAccounts
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer,
getCommunityAccounts, getServerUsers, shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, syncNow, refreshAccounts,
adminGetStats, adminGetUsers, adminDeleteUser, adminGetAccounts, adminRemoveAccount
}}>
{children}
</AccountsContext.Provider>

View File

@@ -6,7 +6,7 @@ import {
DialogActions, CircularProgress, Paper, Chip,
Table, TableBody, TableCell, TableContainer, TableHead, TableRow,
Switch, FormControlLabel, Divider, List, ListItem, ListItemText, ListItemSecondaryAction,
Tabs, Tab, Select, MenuItem, FormControl, InputLabel
Select, MenuItem, FormControl, InputLabel, Tabs, Tab
} from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import AddIcon from '@mui/icons-material/Add';
@@ -20,75 +20,137 @@ import LockResetIcon from '@mui/icons-material/LockReset';
import SettingsIcon from '@mui/icons-material/Settings';
import ShareIcon from '@mui/icons-material/Share';
import GroupAddIcon from '@mui/icons-material/GroupAdd';
import PublicIcon from '@mui/icons-material/Public';
import ShieldIcon from '@mui/icons-material/Shield';
import GppBadIcon from '@mui/icons-material/GppBad';
import PeopleIcon from '@mui/icons-material/People';
import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
import WorkspacePremiumIcon from '@mui/icons-material/WorkspacePremium';
import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings';
import StorageIcon from '@mui/icons-material/Storage';
import GroupIcon from '@mui/icons-material/Group';
import AccountTreeIcon from '@mui/icons-material/AccountTree';
import { useAccounts, type Account } from '../hooks/useAccounts';
import { useAppTheme } from '../theme/ThemeContext';
import type { ThemeType } from '../theme/SteamTheme';
import NebulaBanner from '../components/NebulaBanner';
const AdminPanel: React.FC<{ open: boolean, onClose: () => void }> = ({ open, onClose }) => {
const { adminGetStats, adminGetUsers, adminDeleteUser, adminGetAccounts, adminRemoveAccount } = useAccounts();
const [tab, setTab] = useState(0);
const [stats, setStats] = useState<any>(null);
const [users, setUsers] = useState<any[]>([]);
const [accounts, setAccounts] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
const loadData = async () => {
setLoading(true);
try {
if (tab === 0) setStats(await adminGetStats());
if (tab === 1) setUsers(await adminGetUsers());
if (tab === 2) setAccounts(await adminGetAccounts());
} catch (e) {}
setLoading(false);
};
useEffect(() => { if (open) loadData(); }, [open, tab]);
const handleDeleteUser = async (id: string) => {
if (window.confirm("Wipe this user and all their accounts?")) {
await adminDeleteUser(id);
loadData();
}
};
const handleForceRemove = async (steamId: string) => {
if (window.confirm("Force remove this account from server?")) {
await adminRemoveAccount(steamId);
loadData();
}
};
return (
<Dialog open={open} onClose={onClose} maxWidth="md" fullWidth>
<DialogTitle sx={{ bgcolor: 'background.paper', color: 'text.primary', display: 'flex', alignItems: 'center', gap: 1 }}>
<AdminPanelSettingsIcon color="primary" /> Server Administration
</DialogTitle>
<Tabs value={tab} onChange={(_, v) => setTab(v)} sx={{ bgcolor: 'background.paper', borderBottom: 1, borderColor: 'divider' }}>
<Tab icon={<StorageIcon />} label="Overview" />
<Tab icon={<GroupIcon />} label="Users" />
<Tab icon={<AccountTreeIcon />} label="Global Accounts" />
</Tabs>
<DialogContent sx={{ bgcolor: 'background.paper', minHeight: 400, pt: 2 }}>
{loading ? <Box sx={{ display: 'flex', justifyContent: 'center', mt: 10 }}><CircularProgress /></Box> : (
<>
{tab === 0 && stats && (
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 2, mt: 2 }}>
{[
{ label: 'Total Users', value: stats.users },
{ label: 'Total Accounts', value: stats.accounts },
{ label: 'Active Cooldowns', value: stats.activeCooldowns }
].map((s) => (
<Paper key={s.label} sx={{ p: 3, textAlign: 'center', bgcolor: 'rgba(0,0,0,0.1)' }}>
<Typography variant="h4" color="primary" sx={{ fontWeight: 'bold' }}>{s.value}</Typography>
<Typography variant="caption" color="textSecondary">{s.label}</Typography>
</Paper>
))}
</Box>
)}
{tab === 1 && (
<List>
{users.map(u => (
<ListItem key={u._id} divider sx={{ borderColor: 'divider' }}>
<Avatar src={u.avatar} sx={{ mr: 2 }} />
<ListItemText primary={u.personaName} secondary={u.steamId} primaryTypographyProps={{ color: 'text.primary' }} />
<ListItemSecondaryAction>
<IconButton color="error" onClick={() => handleDeleteUser(u._id)}><DeleteIcon /></IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
)}
{tab === 2 && (
<List>
{accounts.map(a => (
<ListItem key={a.steamId} divider sx={{ borderColor: 'divider' }}>
<Avatar src={a.avatar} variant="square" sx={{ mr: 2 }} />
<ListItemText
primary={a.personaName}
secondary={`Owned by: ${a.addedBy?.personaName || 'Unknown'} (${a.steamId})`}
primaryTypographyProps={{ color: 'text.primary' }}
/>
<ListItemSecondaryAction>
<IconButton color="error" onClick={() => handleForceRemove(a.steamId)}><DeleteIcon /></IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
</List>
)}
</>
)}
</DialogContent>
<DialogActions sx={{ bgcolor: 'background.paper', p: 2 }}>
<Button onClick={onClose} variant="contained" color="inherit">Close Panel</Button>
</DialogActions>
</Dialog>
);
};
const Dashboard: React.FC = () => {
const { currentTheme, setTheme } = useAppTheme();
const {
accounts, isLoading, isSyncing, serverConfig, addAccount, deleteAccount,
switchAccount, openSteamLogin, updateServerConfig, loginToServer,
getCommunityAccounts, syncNow
accounts, isLoading, isSyncing, serverConfig, deleteAccount,
switchAccount, openSteamAppLogin, openSteamLogin, updateServerConfig, loginToServer, syncNow
} = useAccounts();
const [searchTerm, setSearchTerm] = useState('');
const [isAddDialogOpen, setIsAddDialogOpen] = useState(false);
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
const [identifier, setIdentifier] = useState('');
const [addTab, setAddTab] = useState(0);
const [communityAccounts, setCommunityAccounts] = useState<any[]>([]);
const [isCommunityLoading, setIsCommunityLoading] = useState(false);
const [isAdminPanelOpen, setIsAdminPanelOpen] = useState(false);
const [serverUrl, setServerUrl] = useState('');
useEffect(() => {
if (serverConfig?.url) {
setServerUrl(serverConfig.url);
}
if (serverConfig?.url) setServerUrl(serverConfig.url);
}, [serverConfig?.url]);
const loadCommunity = async () => {
setIsCommunityLoading(true);
try {
const data = await getCommunityAccounts();
setCommunityAccounts(Array.isArray(data) ? data : []);
} catch (e) {
} finally {
setIsCommunityLoading(false);
}
};
useEffect(() => {
if (isAddDialogOpen && addTab === 1) {
loadCommunity();
}
}, [isAddDialogOpen, addTab]);
const handleAddAccount = async () => {
if (!identifier) return;
try {
await addAccount({ identifier });
setIsAddDialogOpen(false);
setIdentifier('');
} catch (e) {
console.error("[Dashboard] Add failed:", e);
}
};
const handleAddFromCommunity = async (commAcc: any) => {
try {
await addAccount({ identifier: commAcc.steamId });
setIsAddDialogOpen(false);
} catch (e) { }
};
const saveSettings = async () => {
await updateServerConfig({ url: serverUrl });
alert("Server URL updated!");
@@ -114,6 +176,15 @@ const Dashboard: React.FC = () => {
</Typography>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 2, WebkitAppRegion: 'no-drag' } as any}>
{/* Admin Button - Only visible if isAdmin is true */}
{serverConfig?.isAdmin && (
<Tooltip title="Open Admin Panel">
<IconButton color="primary" onClick={() => setIsAdminPanelOpen(true)}>
<AdminPanelSettingsIcon />
</IconButton>
</Tooltip>
)}
<Box sx={{ display: 'flex', alignItems: 'center', mr: 1 }}>
{isSyncing ? (
<CircularProgress size={16} sx={{ color: 'primary.main', mr: 1 }} />
@@ -148,7 +219,7 @@ const Dashboard: React.FC = () => {
variant="contained"
color="primary"
startIcon={<AddIcon />}
onClick={() => setIsAddDialogOpen(true)}
onClick={() => openSteamAppLogin()}
sx={{ height: 32 }}
>
Add
@@ -194,7 +265,7 @@ const Dashboard: React.FC = () => {
{!isLoading && filteredAccounts.length === 0 && (
<Box sx={{ width: '100%', mt: 10, textAlign: 'center' }}>
<Typography variant="h6" color="textSecondary">
No accounts tracked. Click "Add Account" to get started!
No accounts tracked. Click "Add" to get started!
</Typography>
</Box>
)}
@@ -235,14 +306,7 @@ const Dashboard: React.FC = () => {
InputProps={{
endAdornment: (
<InputAdornment position="end">
<Button
variant="contained"
size="small"
onClick={saveSettings}
sx={{ height: 30 }}
>
Apply
</Button>
<Button variant="contained" size="small" onClick={saveSettings} sx={{ height: 30 }}>Apply</Button>
</InputAdornment>
),
}}
@@ -298,61 +362,8 @@ const Dashboard: React.FC = () => {
</DialogActions>
</Dialog>
{/* Add Account Dialog */}
<Dialog open={isAddDialogOpen} onClose={() => setIsAddDialogOpen(false)} maxWidth="sm" fullWidth>
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary', p: 0 }}>
<Tabs value={addTab} onChange={(_, v) => setAddTab(v)} variant="fullWidth" textColor="inherit" indicatorColor="primary">
<Tab label="Manual Add" icon={<AddIcon />} iconPosition="start" />
<Tab label="From Community" icon={<PublicIcon />} iconPosition="start" disabled={!serverConfig?.token} />
</Tabs>
</DialogTitle>
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2, minHeight: 300 }}>
{addTab === 0 ? (
<>
<Typography variant="body2" color="textSecondary" sx={{ mb: 2 }}>
Enter a SteamID64 or Profile URL. You will need to authenticate to enable full tracking and instant login features.
</Typography>
<TextField
fullWidth
autoFocus
placeholder="SteamID64 or Profile URL"
value={identifier}
onChange={(e) => setIdentifier(e.target.value)}
sx={{ '& .MuiOutlinedInput-root': { backgroundColor: 'rgba(0, 0, 0, 0.1)' } }}
/>
</>
) : (
<Box>
{isCommunityLoading ? (
<Box sx={{ display: 'flex', justifyContent: 'center', p: 4 }}><CircularProgress size={32} /></Box>
) : (
<List>
{communityAccounts
.filter(ca => !safeAccounts.find(a => a.steamId === ca.steamId))
.map((ca) => (
<ListItem key={ca.steamId} divider sx={{ borderColor: 'divider' }}>
<Avatar src={ca.avatar} variant="square" sx={{ width: 32, height: 32, mr: 2 }} />
<ListItemText
primary={ca.personaName}
secondary={ca.steamId}
primaryTypographyProps={{ sx: { color: 'text.primary', fontWeight: 'bold' } }}
/>
<ListItemSecondaryAction>
<Button size="small" variant="contained" onClick={() => handleAddFromCommunity(ca)}>Add</Button>
</ListItemSecondaryAction>
</ListItem>
))}
{communityAccounts.length === 0 && <Typography align="center" color="textSecondary" sx={{ p: 4 }}>No shared accounts found on server.</Typography>}
</List>
)}
</Box>
)}
</DialogContent>
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}>
<Button onClick={() => setIsAddDialogOpen(false)} color="inherit">Cancel</Button>
{addTab === 0 && <Button onClick={handleAddAccount} variant="contained" color="success" disabled={!identifier}>Add</Button>}
</DialogActions>
</Dialog>
{/* Admin Panel */}
<AdminPanel open={isAdminPanelOpen} onClose={() => setIsAdminPanelOpen(false)} />
</Box>
);
};
@@ -365,7 +376,7 @@ const AccountRow: React.FC<{
onSwitch: (login: string) => void,
onAuth: () => void
}> = ({ account, onDelete, onSwitch, onAuth }) => {
const { shareAccountWithUser, getServerUsers, serverConfig } = useAccounts();
const { shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, getServerUsers, serverConfig } = useAccounts();
const [timeLeft, setTimeLeft] = useState<string | null>(null);
const [isShareOpen, setIsShareOpen] = useState(false);
const [targetUserId, setTargetUserId] = useState('');
@@ -376,10 +387,7 @@ const AccountRow: React.FC<{
const isCooldownActive = cooldownDate && !isNaN(cooldownDate.getTime()) && cooldownDate.getTime() > Date.now();
useEffect(() => {
if (!isCooldownActive || !cooldownDate) {
setTimeLeft(null);
return;
}
if (!isCooldownActive || !cooldownDate) { setTimeLeft(null); return; }
const targetTime = cooldownDate.getTime();
const timer = setInterval(() => {
const diff = targetTime - Date.now();
@@ -392,14 +400,9 @@ const AccountRow: React.FC<{
return () => clearInterval(timer);
}, [account?.cooldownExpiresAt, isCooldownActive]);
const avatarSrc = account?.localAvatar
? `steam-resource://${account.localAvatar}`
: (account?.avatar || '');
const avatarSrc = account?.localAvatar ? `steam-resource://${account.localAvatar}` : (account?.avatar || '');
const [imgSrc, setImgSrc] = useState(avatarSrc);
useEffect(() => {
setImgSrc(avatarSrc);
}, [avatarSrc]);
useEffect(() => { setImgSrc(avatarSrc); }, [avatarSrc]);
const handleOpenShare = async () => {
setIsShareOpen(true);
@@ -409,8 +412,7 @@ const AccountRow: React.FC<{
(window as any).electronAPI.getServerUserInfo()
]);
const filtered = (Array.isArray(users) ? users : []).filter(u =>
u.steamId !== selfInfo.steamId &&
u.steamId !== account.steamId
u.steamId !== selfInfo.steamId && u.steamId !== account.steamId
);
setServerUsers(filtered);
} catch (e) {}
@@ -421,70 +423,79 @@ const AccountRow: React.FC<{
setIsSharing(true);
try {
await shareAccountWithUser(account.steamId, targetUserId);
alert(`Account shared successfully!`);
setIsShareOpen(false);
setTargetUserId('');
} catch (e: any) {
alert(e.message || "Failed to share account");
} finally {
setIsSharing(false);
}
} catch (e: any) { alert(e.message || "Failed to share account");
} finally { setIsSharing(false); }
};
const handleRevoke = async (targetSteamId: string) => {
if (!window.confirm("Revoke access for this user?")) return;
try { await revokeAccountAccess(account.steamId, targetSteamId);
} catch (e: any) { alert(e.message); }
};
const handleRevokeAll = async () => {
if (!window.confirm("Completely stop sharing this account?")) return;
try { await revokeAllAccountAccess(account.steamId); setIsShareOpen(false);
} catch (e: any) { alert(e.message); }
};
const isBanned = account?.vacBanned || (account?.gameBans && account.gameBans > 0);
const isShared = account?._id.startsWith('shared_');
// Primary account check
const isPrimaryAccount = serverConfig?.serverSteamId === account.steamId;
// Refined Shared Logic
const isSharedWithYou = account?._id.startsWith('shared_');
const hasSharedMembers = (account as any).sharedWith && (account as any).sharedWith.length > 0;
const showCommunityIcon = isSharedWithYou || hasSharedMembers;
return (
<TableRow sx={{ '&:hover': { background: 'action.hover' }, borderBottom: '1px solid', borderColor: 'divider' }}>
<TableCell>
<Box sx={{ position: 'relative' }}>
<Avatar src={imgSrc} variant="square" sx={{ width: 32, height: 32, border: '1px solid', borderColor: 'divider' }} />
{isShared && (
<Tooltip title="Community Shared Account">
{isPrimaryAccount && (
<Tooltip title="Primary Community Account">
<WorkspacePremiumIcon sx={{ position: 'absolute', top: -8, left: -8, fontSize: 18, color: '#FFD700', filter: 'drop-shadow(0 0 2px rgba(0,0,0,0.5))' }} />
</Tooltip>
)}
{showCommunityIcon && (
<Tooltip title={isSharedWithYou ? "Remote Shared Account" : "Actively Shared with Community"}>
<PeopleIcon sx={{ position: 'absolute', bottom: -4, right: -4, fontSize: 14, color: 'primary.main', bgcolor: 'background.default', borderRadius: '50%', border: '1px solid', borderColor: 'divider', p: 0.2 }} />
</Tooltip>
)}
</Box>
</TableCell>
<TableCell>
<Typography variant="body2" sx={{ fontWeight: 'bold', color: isBanned ? 'error.main' : 'text.primary' }}>
{account?.personaName || 'Unknown'}
</Typography>
<Typography variant="body2" sx={{ fontWeight: 'bold', color: isBanned ? 'error.main' : 'text.primary' }}>{account?.personaName || 'Unknown'}</Typography>
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block' }}>{account?.steamId}</Typography>
</TableCell>
<TableCell>
{isBanned ? (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'error.main' }}>
<GppBadIcon sx={{ fontSize: 16 }} />
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>ACCOUNT BANNED</Typography>
<GppBadIcon sx={{ fontSize: 16 }} /><Typography variant="caption" sx={{ fontWeight: 'bold' }}>BANNED</Typography>
</Box>
<Box sx={{ display: 'flex', gap: 0.5 }}>
{account?.vacBanned && (
<Chip label="VAC" size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
)}
{account?.gameBans ? account.gameBans > 0 && (
<Chip label={`${account.gameBans} GAME`} size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
) : null}
{account?.vacBanned && <Chip label="VAC" size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold' }} />}
{account?.gameBans ? account.gameBans > 0 && <Chip label={`${account.gameBans} GAME`} size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold' }} /> : null}
</Box>
</Box>
) : (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'success.main' }}>
<ShieldIcon sx={{ fontSize: 16 }} />
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>SECURE</Typography>
<ShieldIcon sx={{ fontSize: 16 }} /><Typography variant="caption" sx={{ fontWeight: 'bold' }}>SECURE</Typography>
</Box>
)}
</TableCell>
<TableCell>
{account?.authError ? (
<Box sx={{ display: 'flex', alignItems: 'center', color: 'warning.main', gap: 0.5 }}>
<LockResetIcon sx={{ fontSize: 16 }} />
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>Needs Re-auth</Typography>
<LockResetIcon sx={{ fontSize: 16 }} /><Typography variant="body2" sx={{ fontWeight: 'bold' }}>Needs Re-auth</Typography>
</Box>
) : isCooldownActive ? (
<Box sx={{ display: 'flex', alignItems: 'center', color: 'primary.main', gap: 0.5 }}>
<TimerIcon sx={{ fontSize: 16 }} />
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>{timeLeft}</Typography>
<TimerIcon sx={{ fontSize: 16 }} /><Typography variant="body2" sx={{ fontWeight: 'bold' }}>{timeLeft}</Typography>
</Box>
) : (
<Typography variant="caption" sx={{ color: 'text.secondary' }}>Available</Typography>
@@ -492,95 +503,79 @@ const AccountRow: React.FC<{
</TableCell>
<TableCell align="right">
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 0.5, alignItems: 'center' }}>
{/* Fast Switcher Button - Always available if we have a login name */}
{account.loginName && (
<Button
variant="contained"
size="small"
onClick={() => onSwitch(account.loginName || '')}
sx={{
height: 28,
fontSize: '0.7rem',
bgcolor: 'secondary.main',
'&:hover': { opacity: 0.9 },
minWidth: 60
}}
>
LOGIN
</Button>
variant="contained" size="small" onClick={() => onSwitch(account.loginName || '')}
sx={{ height: 28, fontSize: '0.7rem', bgcolor: 'secondary.main', '&:hover': { opacity: 0.9 }, minWidth: 60 }}
>LOGIN</Button>
)}
{/* Scraper Auth Button - Controls the optional cooldown tracking */}
<Tooltip title={account.steamLoginSecure && !account.authError ? "Session valid - Tracking active" : (account.steamLoginSecure ? "Refresh scraper session" : "Authenticate for cooldown tracking")}>
<Tooltip title={account.steamLoginSecure && !account.authError ? "Tracking active" : "Authenticate for cooldowns"}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<IconButton
size="small"
onClick={onAuth}
disabled={!!(account.steamLoginSecure && !account.authError)}
size="small" onClick={onAuth} disabled={!!(account.steamLoginSecure && !account.authError)}
sx={{
color: account.steamLoginSecure && !account.authError ? 'success.main' : (account.authError ? 'error.main' : 'warning.main'),
border: '1px solid',
borderColor: account.steamLoginSecure && !account.authError ? 'success.main' : 'divider',
borderRadius: 1,
opacity: account.steamLoginSecure && !account.authError ? 1 : 1,
background: account.steamLoginSecure && !account.authError ? 'rgba(163, 207, 6, 0.1)' : 'transparent'
border: '1px solid', borderColor: account.steamLoginSecure && !account.authError ? 'success.main' : 'divider',
borderRadius: 1, background: account.steamLoginSecure && !account.authError ? 'rgba(163, 207, 6, 0.1)' : 'transparent'
}}
>
{account.steamLoginSecure && !account.authError ? <VerifiedUserIcon fontSize="inherit" /> : (account.authError ? <LockResetIcon fontSize="inherit" /> : <BoltIcon fontSize="inherit" />)}
</IconButton>
{account.steamLoginSecure && !account.authError && (
<Typography variant="caption" sx={{ color: 'success.main', fontWeight: 'bold', fontSize: '0.6rem', letterSpacing: '0.5px' }}>
TRACKING
</Typography>
<Typography variant="caption" sx={{ color: 'success.main', fontWeight: 'bold', fontSize: '0.6rem' }}>TRACKING</Typography>
)}
</Box>
</Tooltip>
<Divider orientation="vertical" flexItem sx={{ mx: 0.5, my: 0.5 }} />
<IconButton size="small" onClick={handleOpenShare} disabled={!serverConfig?.token}><ShareIcon fontSize="inherit" sx={{ color: 'primary.main' }}/></IconButton>
<IconButton size="small" sx={{ color: 'text.secondary' }} onClick={() => (window as any).electronAPI.openExternal(account?.profileUrl || '')}><OpenInNewIcon fontSize="inherit"/></IconButton>
<IconButton size="small" sx={{ color: 'error.main' }} onClick={() => onDelete(account?._id || '')}><DeleteIcon fontSize="inherit"/></IconButton>
</Box>
{/* Share Dialog */}
<Dialog open={isShareOpen} onClose={() => setIsShareOpen(false)} maxWidth="xs" fullWidth>
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary' }}>Share Account</DialogTitle>
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary' }}>Permissions</DialogTitle>
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2 }}>
<Typography variant="body2" sx={{ mb: 2 }}>
Select a community member to share this account with.
</Typography>
<FormControl fullWidth size="small" sx={{ mt: 1 }}>
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>GRANT ACCESS</Typography>
<Box sx={{ display: 'flex', gap: 1, mb: 3 }}>
<FormControl fullWidth size="small">
<InputLabel sx={{ color: 'text.secondary' }}>Select User</InputLabel>
<Select
value={targetUserId}
label="Select User"
onChange={(e) => setTargetUserId(e.target.value as string)}
value={targetUserId} label="Select User" onChange={(e) => setTargetUserId(e.target.value as string)}
sx={{ bgcolor: 'rgba(0,0,0,0.1)', color: 'text.primary' }}
>
{serverUsers.map(user => (
{serverUsers
.filter(u => !(account as any).sharedWith?.find((sw: any) => sw.steamId === u.steamId))
.map(user => (
<MenuItem key={user.steamId} value={user.steamId}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<Avatar src={user.avatar} sx={{ width: 24, height: 24 }} />
{user.personaName}
</Box>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}><Avatar src={user.avatar} sx={{ width: 24, height: 24 }} />{user.personaName}</Box>
</MenuItem>
))}
{serverUsers.length === 0 && <MenuItem disabled>No users found on server</MenuItem>}
{serverUsers.length === 0 && <MenuItem disabled>No eligible users found</MenuItem>}
</Select>
</FormControl>
<Button onClick={handleShare} variant="contained" disabled={!targetUserId || isSharing} sx={{ minWidth: 80 }}>{isSharing ? <CircularProgress size={16} color="inherit" /> : "Add"}</Button>
</Box>
<Divider sx={{ my: 2, borderColor: 'divider' }} />
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>CURRENT ACCESS</Typography>
<List size="small" sx={{ bgcolor: 'rgba(0,0,0,0.05)', borderRadius: 1, mb: 2 }}>
{(account as any).sharedWith?.map((sw: any) => (
<ListItem key={sw.steamId} dense divider sx={{ borderColor: 'divider' }}>
<Avatar src={sw.avatar} sx={{ width: 24, height: 24, mr: 1 }} />
<ListItemText primary={sw.personaName} primaryTypographyProps={{ variant: 'body2', sx: { fontWeight: 'bold' } }} />
<ListItemSecondaryAction>
<IconButton size="small" color="error" onClick={() => handleRevoke(sw.steamId)}><DeleteIcon fontSize="inherit" /></IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
{(!(account as any).sharedWith || (account as any).sharedWith.length === 0) && (
<Typography variant="caption" align="center" sx={{ display: 'block', p: 2, opacity: 0.6 }}>Not shared with anyone yet.</Typography>
)}
</List>
{(account as any).sharedWith?.length > 0 && (
<Button fullWidth variant="outlined" color="error" size="small" onClick={handleRevokeAll} startIcon={<GppBadIcon />}>Revoke All Shared Access</Button>
)}
</DialogContent>
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}>
<Button onClick={() => setIsShareOpen(false)} color="inherit" disabled={isSharing}>Cancel</Button>
<Button
onClick={handleShare}
variant="contained"
startIcon={isSharing ? <CircularProgress size={16} color="inherit" /> : <GroupAddIcon />}
disabled={!targetUserId || isSharing}
>
{isSharing ? "Sharing..." : "Grant Access"}
</Button>
</DialogActions>
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}><Button onClick={() => setIsShareOpen(false)} color="inherit" variant="contained">Done</Button></DialogActions>
</Dialog>
</TableCell>
</TableRow>

View File

@@ -0,0 +1,234 @@
const AccountRow: React.FC<{
account: Account,
onDelete: (id: string) => void,
onSwitch: (login: string) => void,
onAuth: () => void
}> = ({ account, onDelete, onSwitch, onAuth }) => {
const { shareAccountWithUser, revokeAccountAccess, revokeAllAccountAccess, getServerUsers, serverConfig } = useAccounts();
const [timeLeft, setTimeLeft] = useState<string | null>(null);
const [isShareOpen, setIsShareOpen] = useState(false);
const [targetUserId, setTargetUserId] = useState('');
const [isSharing, setIsSharing] = useState(false);
const [serverUsers, setServerUsers] = useState<any[]>([]);
const cooldownDate = account?.cooldownExpiresAt ? new Date(account.cooldownExpiresAt) : null;
const isCooldownActive = cooldownDate && !isNaN(cooldownDate.getTime()) && cooldownDate.getTime() > Date.now();
useEffect(() => {
if (!isCooldownActive || !cooldownDate) {
setTimeLeft(null);
return;
}
const targetTime = cooldownDate.getTime();
const timer = setInterval(() => {
const diff = targetTime - Date.now();
if (diff <= 0) { setTimeLeft(null); clearInterval(timer); return; }
const hours = Math.floor(diff / 3600000);
const mins = Math.floor((diff % 3600000) / 60000);
const secs = Math.floor((diff % 60000) / 1000);
setTimeLeft(`${hours}h ${mins}m ${secs}s`);
}, 1000);
return () => clearInterval(timer);
}, [account?.cooldownExpiresAt, isCooldownActive]);
const avatarSrc = account?.localAvatar
? `steam-resource://${account.localAvatar}`
: (account?.avatar || '');
const [imgSrc, setImgSrc] = useState(avatarSrc);
useEffect(() => {
setImgSrc(avatarSrc);
}, [avatarSrc]);
const handleOpenShare = async () => {
setIsShareOpen(true);
try {
const [users, selfInfo] = await Promise.all([
getServerUsers(),
(window as any).electronAPI.getServerUserInfo()
]);
const filtered = (Array.isArray(users) ? users : []).filter(u =>
u.steamId !== selfInfo.steamId &&
u.steamId !== account.steamId
);
setServerUsers(filtered);
} catch (e) {}
};
const handleShare = async () => {
if (!targetUserId) return;
setIsSharing(true);
try {
await shareAccountWithUser(account.steamId, targetUserId);
setTargetUserId('');
} catch (e: any) {
alert(e.message || "Failed to share account");
} finally {
setIsSharing(false);
}
};
const handleRevoke = async (targetSteamId: string) => {
if (!window.confirm("Revoke access for this user?")) return;
try {
await revokeAccountAccess(account.steamId, targetSteamId);
} catch (e: any) { alert(e.message); }
};
const handleRevokeAll = async () => {
if (!window.confirm("Completely stop sharing this account with the community?")) return;
try {
await revokeAllAccountAccess(account.steamId);
setIsShareOpen(false);
} catch (e: any) { alert(e.message); }
};
const isBanned = account?.vacBanned || (account?.gameBans && account.gameBans > 0);
const isShared = account?._id.startsWith('shared_');
return (
<TableRow sx={{ '&:hover': { background: 'action.hover' }, borderBottom: '1px solid', borderColor: 'divider' }}>
<TableCell>
<Box sx={{ position: 'relative' }}>
<Avatar src={imgSrc} variant="square" sx={{ width: 32, height: 32, border: '1px solid', borderColor: 'divider' }} />
{isShared && (
<Tooltip title="Community Shared Account">
<PeopleIcon sx={{ position: 'absolute', bottom: -4, right: -4, fontSize: 14, color: 'primary.main', bgcolor: 'background.default', borderRadius: '50%', border: '1px solid', borderColor: 'divider', p: 0.2 }} />
</Tooltip>
)}
</Box>
</TableCell>
<TableCell>
<Typography variant="body2" sx={{ fontWeight: 'bold', color: isBanned ? 'error.main' : 'text.primary' }}>
{account?.personaName || 'Unknown'}
</Typography>
<Typography variant="caption" sx={{ color: 'text.secondary', display: 'block' }}>{account?.steamId}</Typography>
</TableCell>
<TableCell>
{isBanned ? (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.5 }}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'error.main' }}>
<GppBadIcon sx={{ fontSize: 16 }} />
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>ACCOUNT BANNED</Typography>
</Box>
<Box sx={{ display: 'flex', gap: 0.5 }}>
{account?.vacBanned && (
<Chip label="VAC" size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
)}
{account?.gameBans ? account.gameBans > 0 && (
<Chip label={`${account.gameBans} GAME`} size="small" sx={{ height: 16, fontSize: '0.6rem', bgcolor: 'error.main', color: 'white', fontWeight: 'bold', borderRadius: 0.5 }} />
) : null}
</Box>
</Box>
) : (
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5, color: 'success.main' }}>
<ShieldIcon sx={{ fontSize: 16 }} />
<Typography variant="caption" sx={{ fontWeight: 'bold', letterSpacing: '0.5px' }}>SECURE</Typography>
</Box>
)}
</TableCell>
<TableCell>
{account?.authError ? (
<Box sx={{ display: 'flex', alignItems: 'center', color: 'warning.main', gap: 0.5 }}>
<LockResetIcon sx={{ fontSize: 16 }} />
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>Needs Re-auth</Typography>
</Box>
) : isCooldownActive ? (
<Box sx={{ display: 'flex', alignItems: 'center', color: 'primary.main', gap: 0.5 }}>
<TimerIcon sx={{ fontSize: 16 }} />
<Typography variant="body2" sx={{ fontWeight: 'bold' }}>{timeLeft}</Typography>
</Box>
) : (
<Typography variant="caption" sx={{ color: 'text.secondary' }}>Available</Typography>
)}
</TableCell>
<TableCell align="right">
<Box sx={{ display: 'flex', justifyContent: 'flex-end', gap: 0.5, alignItems: 'center' }}>
{account.loginName && (
<Button
variant="contained" size="small" onClick={() => onSwitch(account.loginName || '')}
sx={{ height: 28, fontSize: '0.7rem', bgcolor: 'secondary.main', '&:hover': { opacity: 0.9 }, minWidth: 60 }}
>
LOGIN
</Button>
)}
<Tooltip title={account.steamLoginSecure && !account.authError ? "Session valid - Tracking active" : (account.steamLoginSecure ? "Refresh scraper session" : "Authenticate for cooldown tracking")}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
<IconButton
size="small" onClick={onAuth}
disabled={!!(account.steamLoginSecure && !account.authError)}
sx={{
color: account.steamLoginSecure && !account.authError ? 'success.main' : (account.authError ? 'error.main' : 'warning.main'),
border: '1px solid', borderColor: account.steamLoginSecure && !account.authError ? 'success.main' : 'divider',
borderRadius: 1, background: account.steamLoginSecure && !account.authError ? 'rgba(163, 207, 6, 0.1)' : 'transparent'
}}
>
{account.steamLoginSecure && !account.authError ? <VerifiedUserIcon fontSize="inherit" /> : (account.authError ? <LockResetIcon fontSize="inherit" /> : <BoltIcon fontSize="inherit" />)}
</IconButton>
{account.steamLoginSecure && !account.authError && (
<Typography variant="caption" sx={{ color: 'success.main', fontWeight: 'bold', fontSize: '0.6rem', letterSpacing: '0.5px' }}>
TRACKING
</Typography>
)}
</Box>
</Tooltip>
<Divider orientation="vertical" flexItem sx={{ mx: 0.5, my: 0.5 }} />
<IconButton size="small" onClick={handleOpenShare} disabled={!serverConfig?.token}><ShareIcon fontSize="inherit" sx={{ color: 'primary.main' }}/></IconButton>
<IconButton size="small" sx={{ color: 'text.secondary' }} onClick={() => (window as any).electronAPI.openExternal(account?.profileUrl || '')}><OpenInNewIcon fontSize="inherit"/></IconButton>
<IconButton size="small" sx={{ color: 'error.main' }} onClick={() => onDelete(account?._id || '')}><DeleteIcon fontSize="inherit"/></IconButton>
</Box>
<Dialog open={isShareOpen} onClose={() => setIsShareOpen(false)} maxWidth="xs" fullWidth>
<DialogTitle sx={{ backgroundColor: 'background.paper', color: 'text.primary' }}>Account Permissions</DialogTitle>
<DialogContent sx={{ backgroundColor: 'background.paper', pt: 2 }}>
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>GRANT ACCESS</Typography>
<Box sx={{ display: 'flex', gap: 1, mb: 3 }}>
<FormControl fullWidth size="small">
<InputLabel sx={{ color: 'text.secondary' }}>Select User</InputLabel>
<Select
value={targetUserId} label="Select User" onChange={(e) => setTargetUserId(e.target.value as string)}
sx={{ bgcolor: 'rgba(0,0,0,0.1)', color: 'text.primary' }}
>
{serverUsers
.filter(u => !(account as any).sharedWith?.find((sw: any) => sw.steamId === u.steamId))
.map(user => (
<MenuItem key={user.steamId} value={user.steamId}>
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}><Avatar src={user.avatar} sx={{ width: 24, height: 24 }} />{user.personaName}</Box>
</MenuItem>
))}
{serverUsers.length === 0 && <MenuItem disabled>No eligible users found</MenuItem>}
</Select>
</FormControl>
<Button onClick={handleShare} variant="contained" disabled={!targetUserId || isSharing} sx={{ minWidth: 80 }}>
{isSharing ? <CircularProgress size={16} color="inherit" /> : "Add"}
</Button>
</Box>
<Divider sx={{ my: 2, borderColor: 'divider' }} />
<Typography variant="subtitle2" sx={{ mb: 1, color: 'primary.main' }}>CURRENT ACCESS</Typography>
<List size="small" sx={{ bgcolor: 'rgba(0,0,0,0.05)', borderRadius: 1, mb: 2 }}>
{(account as any).sharedWith?.map((sw: any) => (
<ListItem key={sw.steamId} dense divider sx={{ borderColor: 'divider' }}>
<Avatar src={sw.avatar} sx={{ width: 24, height: 24, mr: 1 }} />
<ListItemText primary={sw.personaName} primaryTypographyProps={{ variant: 'body2', sx: { fontWeight: 'bold' } }} />
<ListItemSecondaryAction>
<IconButton size="small" color="error" onClick={() => handleRevoke(sw.steamId)}><DeleteIcon fontSize="inherit" /></IconButton>
</ListItemSecondaryAction>
</ListItem>
))}
{(!(account as any).sharedWith || (account as any).sharedWith.length === 0) && (
<Typography variant="caption" align="center" sx={{ display: 'block', p: 2, opacity: 0.6 }}>Not shared with anyone yet.</Typography>
)}
</List>
{(account as any).sharedWith?.length > 0 && (
<Button fullWidth variant="outlined" color="error" size="small" onClick={handleRevokeAll} startIcon={<GppBadIcon />}>Revoke All Shared Access</Button>
)}
</DialogContent>
<DialogActions sx={{ backgroundColor: 'background.paper', p: 2 }}><Button onClick={() => setIsShareOpen(false)} color="inherit" variant="contained">Done</Button></DialogActions>
</Dialog>
</TableCell>
</TableRow>
);
};