Fixes around oauth google login

This commit is contained in:
David Bomba 2022-03-23 10:29:07 +11:00
parent b4f2bba053
commit 15a85da085
2 changed files with 7 additions and 6 deletions

View File

@ -388,13 +388,12 @@ class LoginController extends BaseController
$cu = CompanyUser::query()
->where('user_id', auth()->user()->id);
// $cu->first()->account->companies->each(function ($company) use($cu){
// if($company->tokens()->where('is_system', true)->count() == 0)
// {
// CreateCompanyToken::dispatchNow($company, $cu->first()->user, request()->server('HTTP_USER_AGENT'));
// }
// });
$truth = app()->make(TruthSource::class);
$truth->setCompanyUser($cu->first());
$truth->setUser(auth()->user());
$truth->setCompany(auth()->user()->account->default_company);
if($existing_user->company_users()->count() != $existing_user->tokens()->count())

View File

@ -156,6 +156,8 @@ class User extends Authenticatable implements MustVerifyEmail
return CompanyToken::with(['cu'])->where('token', request()->header('X-API-TOKEN'))->first();
}
if($truth->getCompany())
return $this->tokens()->where('company_id', $truth->getCompany()->id)->first();
return $this->tokens()->first();
}