From 62bc55cf0bb556b6333eedec96895e59a243efd5 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 21 Jan 2021 10:01:13 +1100 Subject: [PATCH] Fixes for client authentication to client portal --- app/Models/ClientContact.php | 11 +---------- app/Repositories/ClientContactRepository.php | 5 +++++ resources/views/email/admin/generic.blade.php | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/Models/ClientContact.php b/app/Models/ClientContact.php index 83907c3953..115fb1e206 100644 --- a/app/Models/ClientContact.php +++ b/app/Models/ClientContact.php @@ -49,10 +49,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference 'hashed_id', ]; - protected $with = [ -// 'client', -// 'company' - ]; + protected $with = []; protected $casts = [ 'updated_at' => 'timestamp', @@ -87,12 +84,6 @@ class ClientContact extends Authenticatable implements HasLocalePreference 'client_id', ]; - /* Changing the username to id allows us to login() a contact that doesn't have an email address set*/ - public function username() - { - return 'id'; - } - public function getEntityType() { return self::class; diff --git a/app/Repositories/ClientContactRepository.php b/app/Repositories/ClientContactRepository.php index ea574f5206..91b3e2ff3f 100644 --- a/app/Repositories/ClientContactRepository.php +++ b/app/Repositories/ClientContactRepository.php @@ -58,6 +58,10 @@ class ClientContactRepository extends BaseRepository $update_contact->client_id = $client->id; } + /* We need to set NULL email addresses to blank strings to pass authentication*/ + if(array_key_exists('email', $contact) && is_null($contact['email'])) + $contact['email'] = ''; + $update_contact->fill($contact); if (array_key_exists('password', $contact) && strlen($contact['password']) > 1) { @@ -77,6 +81,7 @@ class ClientContactRepository extends BaseRepository $new_contact->contact_key = Str::random(40); $new_contact->is_primary = true; $new_contact->confirmed = true; + $new_contact->email = ' '; $new_contact->save(); } } diff --git a/resources/views/email/admin/generic.blade.php b/resources/views/email/admin/generic.blade.php index 579308450f..d08a145a7d 100644 --- a/resources/views/email/admin/generic.blade.php +++ b/resources/views/email/admin/generic.blade.php @@ -5,7 +5,7 @@ @include('email.components.header', ['logo' => $logo]) @endslot -

{{ $title }}

+

{{ $title }}

@slot('greeting') @lang($message)