feat(routes): restrict backup download access to team admins and owners
This commit is contained in:
parent
2934d4a259
commit
82529a3246
1 changed files with 4 additions and 0 deletions
|
|
@ -290,9 +290,13 @@
|
||||||
Route::get('/download/backup/{executionId}', function () {
|
Route::get('/download/backup/{executionId}', function () {
|
||||||
try {
|
try {
|
||||||
$team = auth()->user()->currentTeam();
|
$team = auth()->user()->currentTeam();
|
||||||
|
$user = auth()->user();
|
||||||
if (is_null($team)) {
|
if (is_null($team)) {
|
||||||
return response()->json(['message' => 'Team not found.'], 404);
|
return response()->json(['message' => 'Team not found.'], 404);
|
||||||
}
|
}
|
||||||
|
if ($user->isAdminFromSession() === false) {
|
||||||
|
return response()->json(['message' => 'Only team admins/owners can download backups.'], 403);
|
||||||
|
}
|
||||||
$exeuctionId = request()->route('executionId');
|
$exeuctionId = request()->route('executionId');
|
||||||
$execution = ScheduledDatabaseBackupExecution::where('id', $exeuctionId)->firstOrFail();
|
$execution = ScheduledDatabaseBackupExecution::where('id', $exeuctionId)->firstOrFail();
|
||||||
$execution_team_id = $execution->scheduledDatabaseBackup->database->team()?->id;
|
$execution_team_id = $execution->scheduledDatabaseBackup->database->team()?->id;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue