mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-02 19:04:33 -04:00
Fixes for company tokens on login
This commit is contained in:
parent
eb1547c187
commit
6bab442cc6
@ -221,14 +221,30 @@ class LoginController extends BaseController
|
|||||||
return response()->json(['message' => 'User not linked to any companies'], 403);
|
return response()->json(['message' => 'User not linked to any companies'], 403);
|
||||||
|
|
||||||
/* Ensure the user has a valid token */
|
/* Ensure the user has a valid token */
|
||||||
$user->company_users->each(function ($company_user) use($request){
|
if($user->company_users()->count() != $user->tokens()->count())
|
||||||
|
{
|
||||||
|
|
||||||
|
$user->companies->each(function($company) use($user, $request){
|
||||||
|
|
||||||
|
if(!CompanyToken::where('user_id', $user->id)->where('company_id', $company->id)->exists()){
|
||||||
|
|
||||||
|
CreateCompanyToken::dispatchNow($company, $user, $request->server('HTTP_USER_AGENT'));
|
||||||
|
|
||||||
if($company_user->tokens->count() == 0){
|
|
||||||
CreateCompanyToken::dispatchNow($company_user->company, $company_user->user, $request->server('HTTP_USER_AGENT'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//method above override this
|
||||||
|
// $user->company_users->each(function ($company_user) use($request){
|
||||||
|
|
||||||
|
// if($company_user->tokens->count() == 0){
|
||||||
|
// CreateCompanyToken::dispatchNow($company_user->company, $company_user->user, $request->server('HTTP_USER_AGENT'));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
/*On the hosted platform, only owners can login for free/pro accounts*/
|
/*On the hosted platform, only owners can login for free/pro accounts*/
|
||||||
if(Ninja::isHosted() && !$cu->first()->is_owner && !$user->account->isEnterpriseClient())
|
if(Ninja::isHosted() && !$cu->first()->is_owner && !$user->account->isEnterpriseClient())
|
||||||
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
|
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
|
||||||
|
@ -52,8 +52,6 @@ class QueryLogging
|
|||||||
$timeEnd = microtime(true);
|
$timeEnd = microtime(true);
|
||||||
$time = $timeEnd - $timeStart;
|
$time = $timeEnd - $timeStart;
|
||||||
|
|
||||||
// nlog("Query count = {$count}");
|
|
||||||
|
|
||||||
if($count > 250)
|
if($count > 250)
|
||||||
nlog($queries);
|
nlog($queries);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user