Fix changing a user password to not incorrectly handle logging out old sessions; closes #3531

This commit is contained in:
Dane Everitt 2021-08-15 17:37:12 -07:00
parent 25d9ba4779
commit 2b3303c46b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
5 changed files with 32 additions and 28 deletions

View file

@ -2,10 +2,9 @@
namespace Pterodactyl\Tests\Integration\Api\Client;
use Mockery;
use Pterodactyl\Models\User;
use Illuminate\Http\Response;
use Illuminate\Auth\AuthManager;
use Illuminate\Support\Facades\Hash;
class AccountControllerTest extends ClientApiIntegrationTestCase
{
@ -106,10 +105,7 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
/** @var \Pterodactyl\Models\User $user */
$user = User::factory()->create();
$mock = Mockery::mock(AuthManager::class);
$mock->expects('logoutOtherDevices')->with('New_Password1');
$this->app->instance(AuthManager::class, $mock);
$initialHash = $user->password;
$response = $this->actingAs($user)->putJson('/api/client/account/password', [
'current_password' => 'password',
@ -117,6 +113,12 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
'password_confirmation' => 'New_Password1',
]);
$user = $user->refresh();
$this->assertNotEquals($user->password, $initialHash);
$this->assertTrue(Hash::check('New_Password1', $user->password));
$this->assertFalse(Hash::check('password', $user->password));
$response->assertStatus(Response::HTTP_NO_CONTENT);
}