From d8ffb804d905ff3b611e1c668edfbb66806668a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Thu, 7 Mar 2024 19:13:09 +0100 Subject: [PATCH] Add email validation and check for existing customer in Login component --- app/Livewire/BillingPortal/Authentication/Login.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Livewire/BillingPortal/Authentication/Login.php b/app/Livewire/BillingPortal/Authentication/Login.php index 8217da3ca428..06090998c8ba 100644 --- a/app/Livewire/BillingPortal/Authentication/Login.php +++ b/app/Livewire/BillingPortal/Authentication/Login.php @@ -41,7 +41,17 @@ class Login extends Component public function initial() { - $this->validateOnly('email', ['email' => 'required|bail|email:rfc|exists:client_contacts,email']); + $this->validateOnly('email', ['email' => 'required|bail|email:rfc|email']); + + $contact = ClientContact::where('email', $this->email) + ->where('company_id', $this->subscription->company_id) + ->first(); + + if ($contact === null) { + $this->addError('email', ctrans('texts.checkout_only_for_existing_customers')); + + return; + } $this->state['initial_completed'] = true;