New task - password confirmation

This commit is contained in:
PovilasKorop
2021-11-01 08:36:28 +02:00
parent 355d40f627
commit 0240281ef9
4 changed files with 48 additions and 1 deletions
+12 -1
View File
@@ -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()`.
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()`.
---
+17
View File
@@ -0,0 +1,17 @@
<x-app-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Very secret page') }}
</h2>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
This page should be visible only for those who entered their password again.
</div>
</div>
</div>
</div>
</x-app-layout>
+5
View File
@@ -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';
+14
View File
@@ -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();
}
}