mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-01 09:04:36 -04:00
Fixes for login refactory
This commit is contained in:
parent
ba5037c6da
commit
964563dce4
@ -372,29 +372,26 @@ class LoginController extends BaseController
|
|||||||
private function hydrateCompanyUser() :Builder
|
private function hydrateCompanyUser() :Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
$cu = CompanyUser::query()
|
$cu = CompanyUser::query()->where('user_id', auth()->user()->id);
|
||||||
->where('user_id', auth()->user()->id)
|
|
||||||
->where('company_id', auth()->user()->account->default_company_id);
|
|
||||||
|
|
||||||
if($cu->exists())
|
if(CompanyUser::query()->where('user_id', auth()->user()->id)->where('company_id', auth()->user()->account->default_company_id)->exists())
|
||||||
$set_company = auth()->user()->account->default_company;
|
$set_company = auth()->user()->account->default_company;
|
||||||
else{
|
else{
|
||||||
$cu = CompanyUser::query()->where('user_id', auth()->user()->id);
|
$set_company = $cu->first()->company;
|
||||||
$set_company = $cu->company;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auth()->user()->setCompany($set_company);
|
auth()->user()->setCompany($set_company);
|
||||||
|
|
||||||
$this->setLoginCache(auth()->user());
|
$this->setLoginCache(auth()->user());
|
||||||
|
|
||||||
if($cu->count() == 0)
|
|
||||||
return $cu;
|
|
||||||
|
|
||||||
$truth = app()->make(TruthSource::class);
|
$truth = app()->make(TruthSource::class);
|
||||||
$truth->setCompanyUser($cu->first());
|
$truth->setCompanyUser($cu->first());
|
||||||
$truth->setUser(auth()->user());
|
$truth->setUser(auth()->user());
|
||||||
$truth->setCompany($set_company);
|
$truth->setCompany($set_company);
|
||||||
|
|
||||||
|
if($cu->count() == 0)
|
||||||
|
return $cu;
|
||||||
|
|
||||||
if(auth()->user()->company_users()->count() != auth()->user()->tokens()->count())
|
if(auth()->user()->company_users()->count() != auth()->user()->tokens()->count())
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user