mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-04 01:17:15 +00:00
fix(clients): allow case-only email updates without duplicates (#6050)
Case-only email edits (test → Test) skipped the ClientRecord rename because the gate used strings.EqualFold. SyncInbound then failed its case-sensitive lookup and inserted a second row; the later fallback rename hit UNIQUE constraint failed: clients.email. Rename on any byte-level email difference so the same client is updated in place. Fixes #5951
This commit is contained in:
@@ -807,7 +807,9 @@ func (s *ClientService) UpdateInboundClient(inboundSvc *InboundService, data *mo
|
||||
}
|
||||
// Rename the client record in the same transaction as the settings JSON
|
||||
// so no concurrent SyncInbound can see one renamed without the other.
|
||||
if len(oldEmail) > 0 && !strings.EqualFold(oldEmail, clients[0].Email) {
|
||||
// Byte-level compare (not EqualFold): case-only edits must rename too,
|
||||
// otherwise SyncInbound's case-sensitive lookup creates a duplicate row.
|
||||
if len(oldEmail) > 0 && oldEmail != clients[0].Email {
|
||||
var renameTaken int64
|
||||
if e := tx.Model(&model.ClientRecord{}).Where("email = ?", clients[0].Email).Count(&renameTaken).Error; e != nil {
|
||||
return e
|
||||
|
||||
Reference in New Issue
Block a user