43 lines
790 B
PHP
43 lines
790 B
PHP
<?php
|
|
|
|
namespace App\Http\Livewire\Form;
|
|
|
|
use Livewire\Component;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class LoginForm extends Component
|
|
{
|
|
public $username;
|
|
|
|
public $password;
|
|
|
|
protected $rules = [
|
|
'username' => 'required|string|min:3',
|
|
'password' => 'required|string',
|
|
];
|
|
|
|
public function submit()
|
|
{
|
|
$this->validate();
|
|
|
|
$cred = [
|
|
'username' => $this->username,
|
|
'password' => $this->password
|
|
];
|
|
|
|
if (!Auth::attempt($cred)) {
|
|
session()->flash('message', __('auth.failed'));
|
|
return;
|
|
}
|
|
|
|
return redirect()->intended('/admin');
|
|
}
|
|
|
|
/**
|
|
* Render the setup page
|
|
*/
|
|
public function render()
|
|
{
|
|
return view('form.login');
|
|
}
|
|
}
|