diff --git a/modules/Auth/AuthServiceProvider.php b/modules/Auth/AuthServiceProvider.php
index 85e58e7d..0755bc9d 100644
--- a/modules/Auth/AuthServiceProvider.php
+++ b/modules/Auth/AuthServiceProvider.php
@@ -5,6 +5,7 @@ namespace Modules\Auth;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Modules\Auth\Components\LoginForm;
+use Modules\Auth\Components\PasswordReset;
class AuthServiceProvider extends ServiceProvider
{
@@ -26,6 +27,8 @@ class AuthServiceProvider extends ServiceProvider
{
app(Router::class)->middleware(['web', 'guest'])->group(function ($router) {
$router->get('/login', LoginForm::class)->name('login');
+ $router->get('/password/reset', PasswordReset::class)->name('password.request');
+ $router->get('/password/reseta', PasswordReset::class)->name('password.reset');
});
}
}
diff --git a/modules/Auth/Components/LoginForm.php b/modules/Auth/Components/LoginForm.php
index 3a6d2f8f..e95a90f0 100644
--- a/modules/Auth/Components/LoginForm.php
+++ b/modules/Auth/Components/LoginForm.php
@@ -52,7 +52,7 @@ class LoginForm extends Component
Login
diff --git a/modules/Auth/Components/LoginFormTest.php b/modules/Auth/Components/LoginFormTest.php
index 318598cd..923284a8 100644
--- a/modules/Auth/Components/LoginFormTest.php
+++ b/modules/Auth/Components/LoginFormTest.php
@@ -23,7 +23,8 @@ it('displays component', function () {
it('displays form', function () {
Livewire::test(LoginForm::class)
->assertSee('Login')
- ->assertSee('Passwort vergessen');
+ ->assertSee('Passwort vergessen')
+ ->assertSee(route('password.request'));
});
it('loggs in', function () {
diff --git a/modules/Auth/Components/PasswordReset.php b/modules/Auth/Components/PasswordReset.php
new file mode 100644
index 00000000..d69c8237
--- /dev/null
+++ b/modules/Auth/Components/PasswordReset.php
@@ -0,0 +1,66 @@
+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'
+
+
+
+ HTML;
+ }
+}
diff --git a/modules/Auth/Components/PasswordResetTest.php b/modules/Auth/Components/PasswordResetTest.php
new file mode 100644
index 00000000..8982260e
--- /dev/null
+++ b/modules/Auth/Components/PasswordResetTest.php
@@ -0,0 +1,53 @@
+get(route('password.request'))->assertSeeLivewire(PasswordReset::class)->assertDontSee('Dashboard');
+});
+
+it('shows intro', function () {
+ Livewire::test(PasswordReset::class)->assertSee('Hier kannst du dein Passwort zurücksetzen.');
+});
+
+it('it needs email address', function (string $email, string $error) {
+ Livewire::test(PasswordReset::class)
+ ->set('email', $email)
+ ->call('submit')
+ ->assertHasErrors(['email' => $error]);
+})
+ ->with([
+ ['', 'E-Mail Adresse ist erforderlich.'],
+ ['aaa', 'E-Mail Adresse muss eine gültige E-Mail-Adresse sein.'],
+ ]);
+
+it('displays error when user doesnt exsst', function () {
+ Livewire::test(PasswordReset::class)
+ ->set('email', 'nowhere@example.com')
+ ->call('submit')
+ ->assertHasErrors(['email' => 'Es konnte leider kein Nutzer mit dieser E-Mail-Adresse gefunden werden.']);
+});
+
+it('requests link', function () {
+ Notification::fake();
+ $user = User::factory()->loginData('admin@example.com', 'secret')->create();
+ Livewire::test(PasswordReset::class)
+ ->set('email', 'admin@example.com')
+ ->call('submit')
+ ->assertDispatched('success', 'Du hast weitere Instruktionen per E-Mail erhalten.');
+
+ Notification::assertSentTo($user, ResetPassword::class);
+});