1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-12 14:12:44 +01:00

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