Polish forced password change flow
linter / quality (pull_request) Successful in 1m19s
tests / ci (8.4) (pull_request) Successful in 1m44s

This commit is contained in:
2026-05-22 21:10:14 +00:00
parent 5bb6e57db4
commit 704dd6c26e
3 changed files with 61 additions and 2 deletions
+36
View File
@@ -109,6 +109,20 @@ class SecurityTest extends TestCase
$this->actingAs($user)
->get(route('password.force-change.edit'))
->assertOk()
->assertInertia(fn (Assert $page) => $page
->component('auth/ForcePasswordChange')
->where('status', null),
);
}
public function test_forced_password_change_page_exposes_a_logout_action()
{
$user = User::factory()->create([
'must_change_password_on_next_login' => true,
]);
$this->actingAs($user)
->get(route('password.force-change.edit'))
->assertInertia(fn (Assert $page) => $page
->component('auth/ForcePasswordChange'),
);
@@ -213,4 +227,26 @@ class SecurityTest extends TestCase
->assertSessionHasErrors('current_password')
->assertRedirect(route('security.edit'));
}
public function test_new_password_must_be_different_from_the_current_password()
{
$user = User::factory()->create();
$response = $this
->actingAs($user)
->from(route('security.edit'))
->put(route('user-password.update'), [
'current_password' => 'password',
'password' => 'password',
'password_confirmation' => 'password',
]);
$response
->assertSessionHasErrors([
'password' => 'The new password must be different from your current password.',
])
->assertRedirect(route('security.edit'));
$this->assertTrue(Hash::check('password', $user->fresh()->password));
}
}