mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
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
41 lines
991 B
PHP
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);
|
|
}
|
|
}
|