43 lines
1009 B
PHP
43 lines
1009 B
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Livewire\Auth;
|
||
|
|
|
||
|
|
use Illuminate\Contracts\View\View;
|
||
|
|
use Illuminate\Support\Facades\Auth;
|
||
|
|
use Illuminate\Validation\ValidationException;
|
||
|
|
use Livewire\Attributes\Layout;
|
||
|
|
use Livewire\Component;
|
||
|
|
|
||
|
|
#[Layout('components.layouts.app')]
|
||
|
|
class Login extends Component
|
||
|
|
{
|
||
|
|
public string $email = '';
|
||
|
|
|
||
|
|
public string $password = '';
|
||
|
|
|
||
|
|
public bool $remember = false;
|
||
|
|
|
||
|
|
public function login(): void
|
||
|
|
{
|
||
|
|
$this->validate([
|
||
|
|
'email' => ['required', 'email'],
|
||
|
|
'password' => ['required'],
|
||
|
|
]);
|
||
|
|
|
||
|
|
if (! Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) {
|
||
|
|
throw ValidationException::withMessages([
|
||
|
|
'email' => 'These credentials do not match our records.',
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
session()->regenerate();
|
||
|
|
|
||
|
|
$this->redirect(route('sites.index'), navigate: false);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function render(): View
|
||
|
|
{
|
||
|
|
return view('livewire.auth.login');
|
||
|
|
}
|
||
|
|
}
|