From 444e64a50a0e8803f2e67af84809400409a271d3 Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Fri, 13 Feb 2026 19:37:41 +0300 Subject: [PATCH] feat: Update client insertion logic to use name/email instead of login --- inc/InstallProtocolManager.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/inc/InstallProtocolManager.php b/inc/InstallProtocolManager.php index 18b7467..b1f5f8d 100644 --- a/inc/InstallProtocolManager.php +++ b/inc/InstallProtocolManager.php @@ -1735,10 +1735,10 @@ class InstallProtocolManager continue; } - // Also check by login + // Also check by name/email $email = $xClient['email'] ?? ''; if ($email !== '') { - $chk2 = $pdo->prepare('SELECT id FROM vpn_clients WHERE server_id = ? AND login = ?'); + $chk2 = $pdo->prepare('SELECT id FROM vpn_clients WHERE server_id = ? AND name = ?'); $chk2->execute([$serverId, $email]); if ($chk2->fetch()) { continue; @@ -1766,16 +1766,15 @@ class InstallProtocolManager urlencode($name) ); - $ins = $pdo->prepare('INSERT INTO vpn_clients (server_id, user_id, name, client_ip, public_key, private_key, preshared_key, login, config, protocol_id, status, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())'); + $ins = $pdo->prepare('INSERT INTO vpn_clients (server_id, user_id, name, client_ip, public_key, private_key, preshared_key, config, protocol_id, status, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())'); $ins->execute([ $serverId, $serverData['user_id'] ?? null, $name, - '', + $uuid, // Use UUID as client_ip (unique key requires non-empty value) $uuid, // Store UUID as public_key for X-Ray clients '', '', - $email !== '' ? $email : $uuid, $vlessUrl, $pid ?: null, 'active' // Import as active since they work on the server