Refactor authentication methods in RegisterOrLogin component

This commit is contained in:
Benjamin Beganović 2024-03-14 15:58:32 +01:00
parent f004282310
commit d2a95c2915

View File

@ -93,7 +93,7 @@ class RegisterOrLogin extends Component
session()->flash('message', 'These credentials do not match our records.'); session()->flash('message', 'These credentials do not match our records.');
} }
public function withOtp() public function withOtp(): void
{ {
$contact = ClientContact::where('email', $this->email) $contact = ClientContact::where('email', $this->email)
->where('company_id', $this->subscription->company_id) ->where('company_id', $this->subscription->company_id)
@ -128,7 +128,7 @@ class RegisterOrLogin extends Component
$this->state['otp_form'] = true; $this->state['otp_form'] = true;
} }
public function handleOtp() public function handleOtp(): void
{ {
$this->validate([ $this->validate([
'otp' => 'required|numeric|digits:6', 'otp' => 'required|numeric|digits:6',
@ -160,7 +160,7 @@ class RegisterOrLogin extends Component
$this->registerForm(); $this->registerForm();
} }
public function register(array $data) public function register(array $data): void
{ {
$service = new ClientRegisterService( $service = new ClientRegisterService(
company: $this->subscription->company, company: $this->subscription->company,
@ -190,7 +190,7 @@ class RegisterOrLogin extends Component
); );
$client = $service->createClient([]); $client = $service->createClient([]);
$contact = $service->createClientContact([], $client); $contact = $service->createClientContact(['email' => $this->email], $client);
auth()->guard('contact')->loginUsingId($contact->id, true); auth()->guard('contact')->loginUsingId($contact->id, true);