From 293b12e3482434187a9c9527b4daea0b9eab13c6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 22 Jun 2021 21:14:08 +1000 Subject: [PATCH 1/2] Fixes for login where the user is not attached to an account --- app/Console/Commands/CheckData.php | 1 + app/Http/Controllers/Auth/LoginController.php | 11 +++++++++-- resources/lang/en/texts.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 14785b462ac2..797d74f69066 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -341,6 +341,7 @@ class CheckData extends Command $this->isValid = false; if($this->option('paid_to_date')){ + $this->logMessage("# {$client->id} " . $client->present()->name.' - '.$client->number." Fixing {$client->paid_to_date} to {$total_invoice_payments}"); $client->paid_to_date = $total_invoice_payments; $client->save(); } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index ec7899ab6f0e..b806f69675cd 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -300,7 +300,6 @@ class LoginController extends BaseController $cu = CompanyUser::query() ->where('user_id', $company_token->user_id); - $cu->first()->account->companies->each(function ($company) use($cu, $request){ if($company->tokens()->where('is_system', true)->count() == 0) @@ -309,7 +308,6 @@ class LoginController extends BaseController } }); - if($request->has('current_company') && $request->input('current_company') == 'true') $cu->where("company_id", $company_token->company_id); @@ -361,6 +359,9 @@ class LoginController extends BaseController if ($existing_user = MultiDB::hasUser($query)) { + if(!$existing_user->account) + return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); + Auth::login($existing_user, true); $existing_user->setCompany($existing_user->account->default_company); @@ -387,6 +388,9 @@ class LoginController extends BaseController //If this is a result user/email combo - lets add their OAuth details details if($existing_login_user = MultiDB::hasUser(['email' => $google->harvestEmail($user)])) { + if(!$existing_login_user->account) + return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); + Auth::login($existing_login_user, true); $existing_login_user->setCompany($existing_login_user->account->default_company); @@ -422,6 +426,9 @@ class LoginController extends BaseController if($existing_login_user = MultiDB::hasUser(['email' => $google->harvestEmail($user)])) { + if(!$existing_login_user->account) + return response()->json(['message' => 'User exists, but not attached to any companies! Orphaned user!'], 400); + Auth::login($existing_login_user, true); $existing_login_user->setCompany($existing_login_user->account->default_company); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 070975170120..ac3d8f0e1a31 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3970,7 +3970,7 @@ $LANG = array( 'details_of_recurring_invoice' => 'Here are some details about recurring invoice', 'cancellation' => 'Cancellation', 'about_cancellation' => 'In case you want to stop the recurring invoice, please click the request the cancellation.', - 'cancellation_warning' => 'Warning! You are requesting a cancellation of this service.\n Your service may be cancelled with no further notification to you.', + 'cancellation_warning' => 'Warning! You are requesting a cancellation of this service. Your service may be cancelled with no further notification to you.', 'cancellation_pending' => 'Cancellation pending, we\'ll be in touch!', 'list_of_payments' => 'List of payments', 'payment_details' => 'Details of the payment', From 830cbb179af7de670211a746bf572307b9195aa2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 22 Jun 2021 21:15:14 +1000 Subject: [PATCH 2/2] v5.2.6 --- VERSION.txt | 2 +- config/ninja.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index e60200b54f47..4ddd9ad77ebf 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -5.2.5 \ No newline at end of file +5.2.6 \ No newline at end of file diff --git a/config/ninja.php b/config/ninja.php index 6aa1b314de97..693978986101 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -14,8 +14,8 @@ return [ 'require_https' => env('REQUIRE_HTTPS', true), 'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'), - 'app_version' => '5.2.5', - 'app_tag' => '5.2.5-release', + 'app_version' => '5.2.6', + 'app_tag' => '5.2.6-release', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', 'api_secret' => env('API_SECRET', ''),