diff --git a/src/app/Http/Controllers/ChangePasswordController.php b/src/app/Http/Controllers/ChangePasswordController.php new file mode 100644 index 0000000..bbc2a7f --- /dev/null +++ b/src/app/Http/Controllers/ChangePasswordController.php @@ -0,0 +1,28 @@ +username(), $request->password()); + $adminSetUserPassword->execute($payload); + + Auth::login($user); + Session::regenerate(); + Session::regenerateToken(); + + return redirect()->route('dashboard'); + } +} diff --git a/src/app/Http/Requests/ChangePasswordRequest.php b/src/app/Http/Requests/ChangePasswordRequest.php new file mode 100644 index 0000000..08f04ef --- /dev/null +++ b/src/app/Http/Requests/ChangePasswordRequest.php @@ -0,0 +1,28 @@ + ['required', 'string'], + 'password' => ['required', 'string'], + ]; + } + + public function username(): string + { + return $this->input('username'); + } + + public function password(): string + { + return $this->input('password'); + } +} diff --git a/src/resources/views/force-password-change.blade.php b/src/resources/views/force-password-change.blade.php new file mode 100644 index 0000000..06baae3 --- /dev/null +++ b/src/resources/views/force-password-change.blade.php @@ -0,0 +1,14 @@ +@extends('layouts.app') + +@section('title', 'パスワード変更') + +@section('content') +

パスワード変更

+ +
+ @csrf +

+

+ +
+@endsection diff --git a/src/routes/web.php b/src/routes/web.php index 0c8b843..fd3f838 100644 --- a/src/routes/web.php +++ b/src/routes/web.php @@ -26,6 +26,10 @@ Route::view('/login', 'login')->name('loginForm'); Route::post('/login', LoginController::class)->name('login'); +Route::group(['middleware' => 'signed'], static function () { + Route::view('/change-password/{user}', 'change-password')->name('changePasswordForm'); + Route::post('/change-password/{user}', LogoutController::class)->name('changePassword'); +}); Route::group(['middleware' => 'auth'], static function () { Route::view('/dashboard', 'dashboard')->name('dashboard');