mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Handle edge case where removed user tries to log into the system
This commit is contained in:
parent
352a1fc1c0
commit
0ae42195b2
@ -323,6 +323,9 @@ class LoginController extends BaseController
|
||||
$cu = CompanyUser::query()
|
||||
->where('user_id', $company_token->user_id);
|
||||
|
||||
if($cu->count() == 0)
|
||||
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
|
||||
|
||||
$cu->first()->account->companies->each(function ($company) use($cu, $request){
|
||||
|
||||
if($company->tokens()->where('is_system', true)->count() == 0)
|
||||
@ -393,6 +396,8 @@ class LoginController extends BaseController
|
||||
$cu = CompanyUser::query()
|
||||
->where('user_id', auth()->user()->id);
|
||||
|
||||
if($cu->count() == 0)
|
||||
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
|
||||
|
||||
$truth = app()->make(TruthSource::class);
|
||||
$truth->setCompanyUser($cu->first());
|
||||
@ -444,6 +449,9 @@ class LoginController extends BaseController
|
||||
$cu = CompanyUser::query()
|
||||
->where('user_id', auth()->user()->id);
|
||||
|
||||
if($cu->count() == 0)
|
||||
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
|
||||
|
||||
$truth = app()->make(TruthSource::class);
|
||||
$truth->setCompanyUser($cu->first());
|
||||
$truth->setUser($existing_login_user);
|
||||
@ -499,6 +507,9 @@ class LoginController extends BaseController
|
||||
$cu = CompanyUser::query()
|
||||
->where('user_id', auth()->user()->id);
|
||||
|
||||
if($cu->count() == 0)
|
||||
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
|
||||
|
||||
$truth = app()->make(TruthSource::class);
|
||||
$truth->setCompanyUser($cu->first());
|
||||
$truth->setUser($existing_login_user);
|
||||
@ -558,6 +569,8 @@ class LoginController extends BaseController
|
||||
|
||||
$cu = CompanyUser::whereUserId(auth()->user()->id);
|
||||
|
||||
if($cu->count() == 0)
|
||||
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
|
||||
|
||||
$truth = app()->make(TruthSource::class);
|
||||
$truth->setCompanyUser($cu->first());
|
||||
|
Loading…
x
Reference in New Issue
Block a user