Skip to content

Commit

Permalink
refactor backup download
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Apr 29, 2024
1 parent 360f5db commit 6bb05a6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@

// Route::get('/security', fn () => view('security.index'))->name('security.index');
Route::get('/security/private-key', fn () => view('security.private-key.index', [
'privateKeys' => PrivateKey::ownedByCurrentTeam(['name', 'uuid', 'is_git_related','description'])->get()
'privateKeys' => PrivateKey::ownedByCurrentTeam(['name', 'uuid', 'is_git_related', 'description'])->get()
]))->name('security.private-key.index');
// Route::get('/security/private-key/new', SecurityPrivateKeyCreate::class)->name('security.private-key.create');
Route::get('/security/private-key/{private_key_uuid}', SecurityPrivateKeyShow::class)->name('security.private-key.show');
Expand Down Expand Up @@ -247,10 +247,16 @@
Route::get('/download/backup/{executionId}', function () {
try {
$team = auth()->user()->currentTeam();
if (is_null($team)) {
return response()->json(['message' => 'Team not found.'], 404);
}
$exeuctionId = request()->route('executionId');
$execution = ScheduledDatabaseBackupExecution::where('id', $exeuctionId)->firstOrFail();
// // get team
if ($team->id !== $execution->scheduledDatabaseBackup->database->team()->id) {
$execution_team_id = $execution->scheduledDatabaseBackup->database->team()?->id;
if (is_null($execution_team_id)) {
return response()->json(['message' => 'Team not found.'], 404);
}
if ($team->id !== $execution_team_id) {
return response()->json(['message' => 'Permission denied.'], 403);
}
if (is_null($execution)) {
Expand Down

0 comments on commit 6bb05a6

Please sign in to comment.