Files
coolify/app/Policies/IntegrationTokenPolicy.php
T
Andras Bacsai 379838251b fix(auth): use the resource team in database import, SQLite, and tokens
These paths used the session team after the resource was loaded. After a
team switch in another tab they used the wrong team or denied access.

- ImportForm: use the database team for the server, S3 storages, and
  the import
- SQLite ConnectApplication: list applications of the database team
- IntegrationTokenPolicy: check admin of the token team for view,
  update, and delete
2026-10-05 21:22:33 +02:00

41 lines
991 B
PHP

<?php
namespace App\Policies;
use App\Models\IntegrationToken;
use App\Models\User;
class IntegrationTokenPolicy
{
/**
* Listing and creating tokens happen on the session team's security pages.
*/
public function viewAny(User $user): bool
{
return $user->isAdmin();
}
public function create(User $user): bool
{
return $user->isAdmin();
}
/**
* A loaded token is checked against its own team: the session team can differ.
*/
public function view(User $user, IntegrationToken $integrationToken): bool
{
return $user->isAdminOfTeam((int) $integrationToken->team_id);
}
public function update(User $user, IntegrationToken $integrationToken): bool
{
return $user->isAdminOfTeam((int) $integrationToken->team_id);
}
public function delete(User $user, IntegrationToken $integrationToken): bool
{
return $user->isAdminOfTeam((int) $integrationToken->team_id);
}
}