mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-14 12:16:45 +00:00
fix(server): improve IP uniqueness validation with team-specific error messages
- Refactor server IP duplicate detection to use `first()` instead of `get()->count()` - Add team-scoped validation to distinguish between same-team and cross-team IP conflicts - Update error messages to clarify ownership: "already exists in your team" vs "in use by another team" - Apply consistent validation logic across API, boarding, and server management flows - Add comprehensive test suite for IP uniqueness enforcement across teams
This commit is contained in:
1 parent
0c19464db1
commit
4ec32290cf
7 files changed
+169
-48
No files matched your search
@@ -97,10 +97,13 @@ class ByIp extends Component
|
||||
$this->validate();
|
||||
try {
|
||||
$this->authorize('create', Server::class);
|
||||
if (Server::where('team_id', currentTeam()->id)
|
||||
->where('ip', $this->ip)
|
||||
->exists()) {
|
||||
return $this->dispatch('error', 'This IP/Domain is already in use by another server in your team.');
|
||||
$foundServer = Server::whereIp($this->ip)->first();
|
||||
if ($foundServer) {
|
||||
if ($foundServer->team_id === currentTeam()->id) {
|
||||
return $this->dispatch('error', 'A server with this IP/Domain already exists in your team.');
|
||||
}
|
||||
|
||||
return $this->dispatch('error', 'A server with this IP/Domain is already in use by another team.');
|
||||
}
|
||||
|
||||
if (is_null($this->private_key_id)) {
|
||||
|
||||
Reference in new issue
Block a user