Fix update agentName

This commit is contained in:
2025-10-12 15:54:31 +07:00
parent 32ac342a20
commit 176573ddd1

View File

@@ -168,9 +168,9 @@ public class UserService : IUserService
if (string.IsNullOrEmpty(agentName)) if (string.IsNullOrEmpty(agentName))
throw new Exception("Agent name cannot be empty"); throw new Exception("Agent name cannot be empty");
// Check if agent name is already used // Check if agent name is already used by another user
var existingUser = await _userRepository.GetUserByAgentNameAsync(agentName); var existingUser = await _userRepository.GetUserByAgentNameAsync(agentName);
if (existingUser != null) if (existingUser != null && existingUser.Id != user.Id)
{ {
throw new Exception($"Agent name already used by {existingUser.Name}"); throw new Exception($"Agent name already used by {existingUser.Name}");
} }