1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Updates for protected download route

This commit is contained in:
David Bomba 2023-11-20 09:04:11 +11:00
parent bc5f9c1b8a
commit 7d61b33966
6 changed files with 13 additions and 7 deletions

View File

@ -56,11 +56,14 @@ class ExportController extends BaseController
*/ */
public function index(StoreExportRequest $request) public function index(StoreExportRequest $request)
{ {
/** @var \App\Models\User $user */
$user = auth()->user();
$hash = Str::uuid(); $hash = Str::uuid();
$url = \Illuminate\Support\Facades\URL::temporarySignedRoute('protected_download', now()->addHour(), ['hash' => $hash]); $url = \Illuminate\Support\Facades\URL::temporarySignedRoute('protected_download', now()->addHour(), ['hash' => $hash]);
Cache::put($hash, $url, now()->addHour()); Cache::put($hash, $url, now()->addHour());
CompanyExport::dispatch(auth()->user()->getCompany(), auth()->user(), $hash); CompanyExport::dispatch($user->getCompany(), $user, $hash);
return response()->json(['message' => 'Processing', 'url' => $url], 200); return response()->json(['message' => 'Processing', 'url' => $url], 200);
} }

View File

@ -19,10 +19,10 @@ use Illuminate\Support\Facades\Storage;
class ProtectedDownloadController extends BaseController class ProtectedDownloadController extends BaseController
{ {
public function index(Request $request) public function index(Request $request, string $hash)
{ {
/** @var string $hashed_path */ /** @var string $hashed_path */
$hashed_path = Cache::pull($request->hash); $hashed_path = Cache::pull($hash);
if (!$hashed_path) { if (!$hashed_path) {
throw new SystemError('File no longer available', 404); throw new SystemError('File no longer available', 404);

View File

@ -492,7 +492,7 @@ class CompanyExport implements ShouldQueue
$nmo->company = $company_reference; $nmo->company = $company_reference;
$nmo->settings = $this->company->settings; $nmo->settings = $this->company->settings;
NinjaMailerJob::dispatch($nmo, true); (new NinjaMailerJob($nmo, true))->handle();
UnlinkFile::dispatch(config('filesystems.default'), $storage_path)->delay(now()->addHours(1)); UnlinkFile::dispatch(config('filesystems.default'), $storage_path)->delay(now()->addHours(1));

View File

@ -301,6 +301,9 @@ class Task extends BaseModel
$logged['end_date_raw'] = 0; $logged['end_date_raw'] = 0;
$logged['end_date'] = ctrans('texts.running'); $logged['end_date'] = ctrans('texts.running');
} }
$logged['description'] = $log[2];
$logged['billable'] = $log[3];
$logged['duration'] = $duration; $logged['duration'] = $duration;
return $logged; return $logged;

File diff suppressed because one or more lines are too long

View File

@ -849,7 +849,7 @@ class TemplateService
return [ return [
'number' => (string) $task->number ?: '', 'number' => (string) $task->number ?: '',
'description' => (string) $task->description ?: '', 'description' => (string) $task->description ?: '',
'duration' => $task->duration ?: 0, 'duration' => $task->calcDuration() ?: 0,
'rate' => Number::formatMoney($task->rate ?? 0, $task->client ?? $task->company), 'rate' => Number::formatMoney($task->rate ?? 0, $task->client ?? $task->company),
'rate_raw' => $task->rate ?? 0, 'rate_raw' => $task->rate ?? 0,
'created_at' => $this->translateDate($task->created_at, $task->client ? $task->client->date_format() : $task->company->date_format(), $task->client ? $task->client->locale() : $task->company->locale()), 'created_at' => $this->translateDate($task->created_at, $task->client ? $task->client->date_format() : $task->company->date_format(), $task->client ? $task->client->locale() : $task->company->locale()),