mirror of
https://github.com/10h30/Test-Laravel-Auth-Basics.git
synced 2026-07-11 10:46:16 +09:00
New task - password confirmation
This commit is contained in:
@@ -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()`.
|
||||
|
||||
---
|
||||
|
||||
@@ -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>
|
||||
@@ -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';
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user