adrema/modules/Auth/Components/PasswordReset.php

67 lines
2.1 KiB
PHP
Raw Normal View History

2024-12-08 23:38:03 +01:00
<?php
namespace Modules\Auth\Components;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Layout;
use Livewire\Component;
class PasswordReset extends Component
{
use SendsPasswordResetEmails;
public string $email = '';
protected function validateEmail(Request $request)
{
$this->validate([
'email' => 'required|max:255|string|email',
]);
}
protected function sendResetLinkFailedResponse(Request $request, $response)
{
throw ValidationException::withMessages([
'email' => [trans($response)],
]);
}
protected function credentials(Request $request)
{
return ['email' => $this->email];
}
public function submit()
{
$this->sendResetLinkEmail(request());
$this->dispatch('success', 'Du hast weitere Instruktionen per E-Mail erhalten.');
}
#[Layout('components.layouts.full')]
public function render(): string
{
return <<<'HTML'
<x-page::full heading="Passwort vergessen" title="Passwort vergessen">
<form wire:submit.prevent="submit">
<div class="grid gap-5">
<span class="text-gray-500 text-sm"
>Hier kannst du dein Passwort zurücksetzen.<br />
Gebe dafür die E-Mail-Adresse deines Benutzerkontos ein.<br />
Anschließend bekommst du eine E-Mail<br />
mit weiteren Anweisungen.</span
>
<x-form::text name="email" wire:model="email" label="E-Mail-Adresse"></x-form::text>
<x-ui::button type="submit">Passwort zurücksetzen</x-ui::button>
<div class="flex justify-center">
<a href="/login" class="text-gray-500 text-sm hover:text-gray-300">Zurück zum Login</a>
</div>
</div>
</form>
</x-page::full>
HTML;
}
}