From c6a42b2a9071fc6d1dde1c62faadb7137a9aaf56 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Dec 2021 15:22:16 +1100 Subject: [PATCH 1/3] minor fixes for contact registration --- app/Http/Controllers/Auth/ContactLoginController.php | 3 +-- app/Http/Middleware/ContactRegister.php | 5 ++--- resources/views/portal/ninja2020/auth/register.blade.php | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Auth/ContactLoginController.php b/app/Http/Controllers/Auth/ContactLoginController.php index 328fb8698b8f..fad924f812a6 100644 --- a/app/Http/Controllers/Auth/ContactLoginController.php +++ b/app/Http/Controllers/Auth/ContactLoginController.php @@ -96,7 +96,7 @@ class ContactLoginController extends Controller return $this->sendLockoutResponse($request); } - if(Ninja::isHosted() && $company = Company::where('company_key', $request->input('company_key'))->first()){ + if(Ninja::isHosted() && $request->has('password') && $company = Company::where('company_key', $request->input('company_key'))->first()){ $contact = ClientContact::where(['email' => $request->input('email'), 'company_id' => $company->id])->first(); @@ -132,7 +132,6 @@ class ContactLoginController extends Controller public function authenticated(Request $request, ClientContact $client) { - // Auth::guard('contact')->loginUsingId($client->id, true); auth()->guard('contact')->loginUsingId($client->id, true); event(new ContactLoggedIn($client, $client->company, Ninja::eventVars())); diff --git a/app/Http/Middleware/ContactRegister.php b/app/Http/Middleware/ContactRegister.php index 2b3a72e1653b..6c8922ff65ba 100644 --- a/app/Http/Middleware/ContactRegister.php +++ b/app/Http/Middleware/ContactRegister.php @@ -37,15 +37,14 @@ class ContactRegister if(! $company->client_can_register) abort(400, 'Registration disabled'); - // $request->merge(['key' => $company->company_key]); - session()->put('key', $company->company_key); + session()->put('key', $company->company_key); return $next($request); } } - $query = [ + $query = [ 'portal_domain' => $request->getSchemeAndHttpHost(), 'portal_mode' => 'domain', ]; diff --git a/resources/views/portal/ninja2020/auth/register.blade.php b/resources/views/portal/ninja2020/auth/register.blade.php index 8396864c1d94..a3fa0befc8ce 100644 --- a/resources/views/portal/ninja2020/auth/register.blade.php +++ b/resources/views/portal/ninja2020/auth/register.blade.php @@ -11,6 +11,10 @@

{{ ctrans('texts.register_label') }}

+ @if($company) + + @endif + @csrf
From d8bdf23f8fa76f6e96bde4426fd142892e9a4505 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Dec 2021 18:19:01 +1100 Subject: [PATCH 2/3] Minor fixes for company imports --- app/Jobs/Company/CompanyImport.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Jobs/Company/CompanyImport.php b/app/Jobs/Company/CompanyImport.php index 605614b36367..d14b042dc778 100644 --- a/app/Jobs/Company/CompanyImport.php +++ b/app/Jobs/Company/CompanyImport.php @@ -1332,15 +1332,17 @@ class CompanyImport implements ShouldQueue if(array_key_exists('deleted_at', $obj_array) && $obj_array['deleted_at'] > 1){ $obj_array['deleted_at'] = now(); } - + /* New to convert product ids from old hashes to new hashes*/ if($class == 'App\Models\Subscription'){ - //$obj_array['product_ids'] = $this->recordProductIds($obj_array['product_ids']); - //$obj_array['recurring_product_ids'] = $this->recordProductIds($obj_array['recurring_product_ids']); - // $obj_array['webhook_configuration'] = json_encode($obj_array['webhook_configuration']); - $obj_array['webhook_configuration'] = ''; + + if(array_key_exists('company', $obj_array)) + unset($obj_array['company']); + + $obj_array['webhook_configuration'] = (array)$obj_array['webhook_configuration']; $obj_array['recurring_product_ids'] = ''; $obj_array['product_ids'] = ''; + nlog($obj_array); } /* Expenses that don't have a number will not be inserted - so need to override here*/ From 3f59c213b45d454586441c8c536f4e1097d1ab0e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 13 Dec 2021 20:31:28 +1100 Subject: [PATCH 3/3] Minor fixes for client statements --- app/Services/Client/Statement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index daafb5bb4973..7c2525204721 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -172,7 +172,7 @@ class Statement $item->tax_rate1 = 5; } - $product = Product::all()->random(); + $product = Product::first(); $item->cost = (float) $product->cost; $item->product_key = $product->product_key;