Skip to content

Commit 900426b

Browse files
[1.x] Require password and confirmation (#245)
* Require password and confirmation * Update NewPasswordController.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent dc0dbb4 commit 900426b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Http/Controllers/NewPasswordController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ public function store(Request $request): Responsable
5757
$request->validate([
5858
'token' => 'required',
5959
Fortify::email() => 'required|email',
60+
'password' => 'required|confirmed',
61+
'password_confirmation' => 'required',
6062
]);
6163

6264
// Here we will attempt to reset the user's password. If it is successful we

tests/NewPasswordControllerTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ public function test_password_reset_can_fail()
6161
{
6262
Password::shouldReceive('broker')->andReturn($broker = Mockery::mock(PasswordBroker::class));
6363

64-
$guard = $this->mock(StatefulGuard::class);
65-
$user = Mockery::mock(Authenticatable::class);
66-
6764
$broker->shouldReceive('reset')->andReturnUsing(function ($input, $callback) {
6865
return Password::INVALID_TOKEN;
6966
});
@@ -130,4 +127,15 @@ public function test_password_can_be_reset_with_customized_email_address_field()
130127
$response->assertStatus(302);
131128
$response->assertRedirect('/login');
132129
}
130+
131+
public function test_password_and_password_confirmation_are_required()
132+
{
133+
$response = $this->post('/reset-password', [
134+
'token' => 'token',
135+
'email' => '[email protected]',
136+
]);
137+
138+
$response->assertStatus(302);
139+
$response->assertSessionHasErrors(['password', 'password_confirmation']);
140+
}
133141
}

0 commit comments

Comments
 (0)