45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Auth;
|
|
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Facades\Password;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Attributes\Validate;
|
|
use Livewire\Component;
|
|
use TallStackUi\Traits\Interactions;
|
|
|
|
#[Layout('components.layouts.login')]
|
|
class ForgotPassword extends Component
|
|
{
|
|
use Interactions;
|
|
|
|
#[Validate('required|email')]
|
|
public $email = '';
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.auth.forgot-password');
|
|
}
|
|
|
|
public function recover(): void
|
|
{
|
|
$this->validate();
|
|
|
|
$status = Password::sendResetLink(['email' => $this->email]);
|
|
|
|
if ($status === Password::RESET_LINK_SENT) {
|
|
$this->dialog()->success('Correo enviado', __($status))
|
|
->confirm(method: 'redirectToLogin')
|
|
->send();
|
|
} else {
|
|
$this->dialog()->error('Error', __($status))->send();
|
|
}
|
|
}
|
|
|
|
public function redirectToLogin(): void
|
|
{
|
|
$this->redirect(route('login'));
|
|
}
|
|
}
|