fix(policies): ensure instance-level databases use root team
Instance-level databases like coolify-db (with id = 0) should always be assigned to the root team (id = 0) rather than attempting to resolve their team from the database object itself.
This commit is contained in:
parent
dbbc77830e
commit
cebef8e258
1 changed files with 5 additions and 0 deletions
|
|
@ -109,6 +109,11 @@ public function manageEnvironment(User $user, $database): bool
|
||||||
|
|
||||||
private function getTeamId($database): ?int
|
private function getTeamId($database): ?int
|
||||||
{
|
{
|
||||||
|
// Instance-level databases (e.g., coolify-db) belong to root team
|
||||||
|
if (isset($database->id) && $database->id === 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (method_exists($database, 'team')) {
|
if (method_exists($database, 'team')) {
|
||||||
return $database->team()?->id;
|
return $database->team()?->id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue