-
-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[5.x] When a user changes their password, delete any password reset t…
…okens (#10694)
- Loading branch information
1 parent
6a1ba7b
commit 121c5e2
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Tests\Tags\User; | ||
|
||
use Illuminate\Support\Facades\Password; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use Statamic\Facades\Parse; | ||
use Statamic\Facades\User; | ||
|
@@ -312,4 +313,25 @@ public function it_handles_precognitive_requests() | |
|
||
$response->assertStatus(422); | ||
} | ||
|
||
#[Test] | ||
public function it_will_delete_any_password_reset_tokens_when_updating_password() | ||
{ | ||
$user = tap(User::make()->email('[email protected]')->password('mypassword'))->save(); | ||
|
||
$token = Password::createToken($user); | ||
|
||
$this->assertTrue(Password::tokenExists($user, $token)); | ||
|
||
$this | ||
->actingAs($user) | ||
->post('/!/auth/password', [ | ||
'current_password' => 'mypassword', | ||
'password' => 'newpassword', | ||
'password_confirmation' => 'newpassword', | ||
]) | ||
->assertSessionHasNoErrors(); | ||
|
||
$this->assertFalse(Password::tokenExists($user, $token)); | ||
} | ||
} |