diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php deleted file mode 100644 index a2d83dcc..00000000 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ /dev/null @@ -1,50 +0,0 @@ -route()->parameter('token'); - - return Inertia::render('authentication/PasswordResetConfirm', [ - 'token' => $token, - 'email' => $request->email, - ]); - } -} diff --git a/modules/Auth/AuthServiceProvider.php b/modules/Auth/AuthServiceProvider.php index 0755bc9d..ed3ff5ed 100644 --- a/modules/Auth/AuthServiceProvider.php +++ b/modules/Auth/AuthServiceProvider.php @@ -6,6 +6,7 @@ use Illuminate\Routing\Router; use Illuminate\Support\ServiceProvider; use Modules\Auth\Components\LoginForm; use Modules\Auth\Components\PasswordReset; +use Modules\Auth\Components\PasswordResetConfirm; class AuthServiceProvider extends ServiceProvider { @@ -28,7 +29,7 @@ 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'); + $router->get('/password/reset/{token}', PasswordResetConfirm::class)->name('password.reset'); }); } } diff --git a/modules/Auth/Components/PasswordResetConfirm.php b/modules/Auth/Components/PasswordResetConfirm.php new file mode 100644 index 00000000..949322f9 --- /dev/null +++ b/modules/Auth/Components/PasswordResetConfirm.php @@ -0,0 +1,87 @@ +email = request()->query('email'); + $this->token = $token; + } + + public function submit() + { + $this->validate([ + 'token' => 'required', + 'email' => 'required|email', + 'password' => ['required', 'confirmed', PasswordRule::defaults()], + ]); + + $response = Password::broker()->reset([ + 'email' => $this->email, + 'password' => $this->password, + 'password_confirmation' => $this->password_confirmation, + 'token' => $this->token + ], fn ($user, $password) => $this->resetPassword($user, $password)); + + if ($response == Password::PASSWORD_RESET) { + $this->dispatch('success', 'Passwort erfolgreich geändert.'); + return redirect()->route('home'); + } + + ValidationException::withMessages([ + 'password' => 'Passwort konnte nicht geändert werden.', + ]); + } + + protected function resetPassword($user, $password) + { + $user->password = Hash::make($password); + $user->setRememberToken(Str::random(60)); + $user->save(); + event(new PasswordReset($user)); + auth()->login($user); + } + + #[Layout('components.layouts.full')] + public function render(): string + { + return <<<'HTML' + +
+
+ + Hier kannst du dein Passwort zurücksetzen.
+ Gebe dafür ein neues Passwort ein.
+ Merke oder notiere dir dieses Passwort, bevor du das Formular absendest.
+ Danach wirst du zum Dashboard weitergeleitet. +
+ + + + Passwort zurücksetzen + +
+
+
+ HTML; + } +} diff --git a/resources/js/views/authentication/PasswordReset.vue b/resources/js/views/authentication/PasswordReset.vue deleted file mode 100644 index ac46418a..00000000 --- a/resources/js/views/authentication/PasswordReset.vue +++ /dev/null @@ -1,44 +0,0 @@ - - - diff --git a/resources/js/views/authentication/PasswordResetConfirm.vue b/resources/js/views/authentication/PasswordResetConfirm.vue deleted file mode 100644 index 6a44c06a..00000000 --- a/resources/js/views/authentication/PasswordResetConfirm.vue +++ /dev/null @@ -1,62 +0,0 @@ - - -