diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 01a5e9e06e7e..2001029e7611 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -160,7 +160,9 @@ class CheckData extends Command private function checkCompanyTokens() { - CompanyUser::doesnthave('token')->cursor()->each(function ($cu) { + CompanyUser::whereDoesntHave('token', function ($query){ + return $query->where('is_system', 1); + })->cursor()->each(function ($cu){ if ($cu->user) { $this->logMessage("Creating missing company token for user # {$cu->user->id} for company id # {$cu->company->id}"); (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle(); @@ -169,7 +171,12 @@ class CheckData extends Command } }); } - + + /** + * checkOauthSanity + * + * @return void + */ private function checkOauthSanity() { User::where('oauth_provider_id', '1')->cursor()->each(function ($user) { diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index a0f030f36bc7..413bf66a3118 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -377,7 +377,7 @@ class LoginController extends BaseController if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) { auth()->user()->companies->each(function ($company) { - if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->exists()) { + if (!CompanyToken::where('user_id', auth()->user()->id)->where('company_id', $company->id)->where('is_system',true)->exists()) { (new CreateCompanyToken($company, auth()->user(), 'Google_O_Auth'))->handle(); } }); diff --git a/app/Services/Quote/SendEmail.php b/app/Services/Quote/SendEmail.php index 388f86447382..de40d309e0d7 100644 --- a/app/Services/Quote/SendEmail.php +++ b/app/Services/Quote/SendEmail.php @@ -45,7 +45,6 @@ class SendEmail $this->reminder_template = $this->quote->calculateTemplate('quote'); } - // $mo = new MailObject(); $this->quote->service()->markSent()->save();