diff --git a/README.md b/README.md index f5da876..8341668 100644 --- a/README.md +++ b/README.md @@ -67,4 +67,15 @@ You need to make changes to two files. In file `routes/web.php` add a Middleware to `/secretpage` URL. And enable email verification in the `app/Models/User.php` file. -Test method: `test_email_can_be_verified()`. \ No newline at end of file +Test method: `test_email_can_be_verified()`. + +--- + +## Task 6. Password Confirmation. + +Make the URL `/verysecretpage` redirect to a page to re-enter their password once again. +In file `routes/web.php` add a Middleware to that URL. + +Test method: `test_password_confirmation_page()`. + +--- diff --git a/resources/views/verysecretpage.blade.php b/resources/views/verysecretpage.blade.php new file mode 100644 index 0000000..5ddc5f3 --- /dev/null +++ b/resources/views/verysecretpage.blade.php @@ -0,0 +1,17 @@ + + +

+ {{ __('Very secret page') }} +

+
+ +
+
+
+
+ This page should be visible only for those who entered their password again. +
+
+
+
+
diff --git a/routes/web.php b/routes/web.php index 1cd68ec..71d0429 100644 --- a/routes/web.php +++ b/routes/web.php @@ -28,4 +28,9 @@ Route::put('profile', [\App\Http\Controllers\ProfileController::class, 'update'] Route::view('/secretpage', 'secretpage') ->name('secretpage'); +// Task: this "/verysecretpage" URL should ask user for verifying their password once again +// You need to add some middleware here +Route::view('/verysecretpage', 'verysecretpage') + ->name('verysecretpage'); + require __DIR__.'/auth.php'; diff --git a/tests/Feature/AuthenticationTest.php b/tests/Feature/AuthenticationTest.php index df79777..1b5308f 100644 --- a/tests/Feature/AuthenticationTest.php +++ b/tests/Feature/AuthenticationTest.php @@ -116,4 +116,18 @@ class AuthenticationTest extends TestCase $response = $this->get('/secretpage'); $response->assertOk(); } + + public function test_password_confirmation_page() + { + $user = User::factory()->create(); + $response = $this->actingAs($user)->get('/verysecretpage'); + $response->assertRedirect('/confirm-password'); + + $response = $this->actingAs($user)->post('/confirm-password', [ + 'password' => 'password', + ]); + + $response->assertRedirect(); + $response->assertSessionHasNoErrors(); + } }