mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-31 10:14:15 +00:00
fix(clients): preserve UUID when toggling enable from clients page
The clients list returns slim rows without secrets (uuid/password/auth) or flow/security/tgId/reset/group. setEnable built its update payload straight from the slim row, sending an empty id, so the backend treated it as a new client and regenerated the UUID (and dropped the omitted fields). Hydrate the full record first and send a complete payload that changes only the enable flag.
This commit is contained in:
parent
8a28373a01
commit
8e301dbca9
1 changed files with 22 additions and 11 deletions
|
|
@ -397,20 +397,31 @@ export function useClients() {
|
||||||
|
|
||||||
const setEnable = useCallback(async (client: ClientRecord, enable: boolean) => {
|
const setEnable = useCallback(async (client: ClientRecord, enable: boolean) => {
|
||||||
if (!client?.email) return null;
|
if (!client?.email) return null;
|
||||||
const payload = {
|
const full = await hydrate(client.email);
|
||||||
email: client.email,
|
const base = full?.client;
|
||||||
subId: client.subId,
|
if (!base) return null;
|
||||||
id: client.uuid,
|
const payload: Record<string, unknown> = {
|
||||||
password: client.password,
|
email: base.email,
|
||||||
auth: client.auth,
|
subId: base.subId,
|
||||||
totalGB: client.totalGB || 0,
|
id: base.uuid,
|
||||||
expiryTime: client.expiryTime || 0,
|
password: base.password,
|
||||||
limitIp: client.limitIp || 0,
|
auth: base.auth,
|
||||||
comment: client.comment || '',
|
flow: base.flow || '',
|
||||||
|
security: base.security || 'auto',
|
||||||
|
totalGB: base.totalGB || 0,
|
||||||
|
expiryTime: base.expiryTime || 0,
|
||||||
|
limitIp: base.limitIp || 0,
|
||||||
|
tgId: Number(base.tgId) || 0,
|
||||||
|
reset: Number(base.reset) || 0,
|
||||||
|
group: base.group || '',
|
||||||
|
comment: base.comment || '',
|
||||||
enable: !!enable,
|
enable: !!enable,
|
||||||
};
|
};
|
||||||
|
if (base.reverse?.tag) {
|
||||||
|
payload.reverse = { tag: base.reverse.tag };
|
||||||
|
}
|
||||||
return update(client.email, payload);
|
return update(client.email, payload);
|
||||||
}, [update]);
|
}, [hydrate, update]);
|
||||||
|
|
||||||
// WS-driven in-place merges. Page wires these via useWebSocket; the bridge
|
// WS-driven in-place merges. Page wires these via useWebSocket; the bridge
|
||||||
// covers coarse 'invalidate' and 'inbounds' events centrally.
|
// covers coarse 'invalidate' and 'inbounds' events centrally.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue