Fixes for company token sanity

This commit is contained in:
David Bomba 2023-03-14 07:25:27 +11:00
parent 4d9065624b
commit 42adc4d897
3 changed files with 10 additions and 4 deletions

View File

@ -160,7 +160,9 @@ class CheckData extends Command
private function checkCompanyTokens() 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) { if ($cu->user) {
$this->logMessage("Creating missing company token for user # {$cu->user->id} for company id # {$cu->company->id}"); $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(); (new CreateCompanyToken($cu->company, $cu->user, 'System'))->handle();
@ -170,6 +172,11 @@ class CheckData extends Command
}); });
} }
/**
* checkOauthSanity
*
* @return void
*/
private function checkOauthSanity() private function checkOauthSanity()
{ {
User::where('oauth_provider_id', '1')->cursor()->each(function ($user) { User::where('oauth_provider_id', '1')->cursor()->each(function ($user) {

View File

@ -377,7 +377,7 @@ class LoginController extends BaseController
if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) { if (auth()->user()->company_users()->count() != auth()->user()->tokens()->distinct('company_id')->count()) {
auth()->user()->companies->each(function ($company) { 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(); (new CreateCompanyToken($company, auth()->user(), 'Google_O_Auth'))->handle();
} }
}); });

View File

@ -45,7 +45,6 @@ class SendEmail
$this->reminder_template = $this->quote->calculateTemplate('quote'); $this->reminder_template = $this->quote->calculateTemplate('quote');
} }
// $mo = new MailObject();
$this->quote->service()->markSent()->save(); $this->quote->service()->markSent()->save();