mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-07 00:23:26 +00:00
fix(api): use explicit team ID for S3 storage lookup in backup endpoints
Replace `ownedByCurrentTeam()` (session-based) with `ownedByCurrentTeamAPI($teamId)` (explicit team ID) when resolving S3 storage in create_backup and update_backup. Session-based team resolution is unreliable in API context where auth is token-based. Add `S3Storage::ownedByCurrentTeamAPI(int $teamId)` scope and update feature tests to use real model instances instead of Mockery mocks.
This commit is contained in:
@@ -66,6 +66,13 @@ class S3Storage extends BaseModel
|
||||
return S3Storage::whereTeamId(currentTeam()->id)->select($selectArray->all())->orderBy('name');
|
||||
}
|
||||
|
||||
public static function ownedByCurrentTeamAPI(int $teamId, array $select = ['*'])
|
||||
{
|
||||
$selectArray = collect($select)->concat(['id']);
|
||||
|
||||
return S3Storage::whereTeamId($teamId)->select($selectArray->all())->orderBy('name');
|
||||
}
|
||||
|
||||
public function isUsable()
|
||||
{
|
||||
return $this->is_usable;
|
||||
|
||||
Reference in New Issue
Block a user