diff --git a/app/Jobs/ImportData.php b/app/Jobs/ImportData.php index 6b9104707e..6f13e93c6a 100644 --- a/app/Jobs/ImportData.php +++ b/app/Jobs/ImportData.php @@ -55,8 +55,10 @@ class ImportData extends Job implements ShouldQueue { $includeSettings = false; - Auth::onceUsingId($this->user->id); - $this->user->account->loadLocalizationSettings(); + if (App::runningInConsole()) { + Auth::onceUsingId($this->user->id); + $this->user->account->loadLocalizationSettings(); + } if ($this->type === IMPORT_JSON) { $includeData = $this->settings['include_data']; @@ -78,6 +80,8 @@ class ImportData extends Job implements ShouldQueue $message = $importService->presentResults($results, $includeSettings); $userMailer->sendMessage($this->user, $subject, $message); - Auth::logout(); + if (App::runningInConsole()) { + Auth::logout(); + } } } diff --git a/app/Jobs/SendInvoiceEmail.php b/app/Jobs/SendInvoiceEmail.php index a9a6931338..04168b609f 100644 --- a/app/Jobs/SendInvoiceEmail.php +++ b/app/Jobs/SendInvoiceEmail.php @@ -63,7 +63,7 @@ class SendInvoiceEmail extends Job implements ShouldQueue { // send email as user if (App::runningInConsole() && $this->userId) { - Auth::loginUsingId($this->userId); + Auth::onceUsingId($this->userId); } $mailer->sendInvoice($this->invoice, $this->reminder, $this->template);