Фикс бага с повторным добавлением аккаунта в authserver

This commit is contained in:
ErickSkrauch 2016-10-15 17:35:03 +03:00
parent bafac25baf
commit 4b6bfa15ec
2 changed files with 4 additions and 5 deletions

View File

@ -80,6 +80,7 @@ class AuthenticationForm extends Form {
$accessTokenModel->insert(); $accessTokenModel->insert();
} else { } else {
$accessTokenModel->refreshPrimaryKeyValue(); $accessTokenModel->refreshPrimaryKeyValue();
$accessTokenModel->update();
} }
return $accessTokenModel; return $accessTokenModel;

View File

@ -89,7 +89,6 @@ class AuthenticationFormTest extends DbTestCase {
public function testCreateMinecraftAccessToken() { public function testCreateMinecraftAccessToken() {
$authForm = new AuthenticationForm(); $authForm = new AuthenticationForm();
$fixturesCount = count($this->minecraftAccessKeys->data);
$authForm->clientToken = Uuid::uuid4(); $authForm->clientToken = Uuid::uuid4();
/** @var Account $account */ /** @var Account $account */
$account = $this->accounts->getModel('admin'); $account = $this->accounts->getModel('admin');
@ -98,12 +97,11 @@ class AuthenticationFormTest extends DbTestCase {
$this->assertInstanceOf(MinecraftAccessKey::class, $result); $this->assertInstanceOf(MinecraftAccessKey::class, $result);
$this->assertEquals($account->id, $result->account_id); $this->assertEquals($account->id, $result->account_id);
$this->assertEquals($authForm->clientToken, $result->client_token); $this->assertEquals($authForm->clientToken, $result->client_token);
$this->assertEquals($fixturesCount + 1, MinecraftAccessKey::find()->count()); $this->assertInstanceOf(MinecraftAccessKey::class, MinecraftAccessKey::findOne($result->access_token));
} }
public function testCreateMinecraftAccessTokenWithExistsClientId() { public function testCreateMinecraftAccessTokenWithExistsClientId() {
$authForm = new AuthenticationForm(); $authForm = new AuthenticationForm();
$fixturesCount = count($this->minecraftAccessKeys->data);
$authForm->clientToken = $this->minecraftAccessKeys['admin-token']['client_token']; $authForm->clientToken = $this->minecraftAccessKeys['admin-token']['client_token'];
/** @var Account $account */ /** @var Account $account */
$account = $this->accounts->getModel('admin'); $account = $this->accounts->getModel('admin');
@ -112,7 +110,8 @@ class AuthenticationFormTest extends DbTestCase {
$this->assertInstanceOf(MinecraftAccessKey::class, $result); $this->assertInstanceOf(MinecraftAccessKey::class, $result);
$this->assertEquals($account->id, $result->account_id); $this->assertEquals($account->id, $result->account_id);
$this->assertEquals($authForm->clientToken, $result->client_token); $this->assertEquals($authForm->clientToken, $result->client_token);
$this->assertEquals($fixturesCount, MinecraftAccessKey::find()->count()); $this->assertNull(MinecraftAccessKey::findOne($this->minecraftAccessKeys['admin-token']['access_token']));
$this->assertInstanceOf(MinecraftAccessKey::class, MinecraftAccessKey::findOne($result->access_token));
} }
private function createAuthForm($status = Account::STATUS_ACTIVE) { private function createAuthForm($status = Account::STATUS_ACTIVE) {
@ -143,5 +142,4 @@ class AuthenticationFormTest extends DbTestCase {
return $authForm; return $authForm;
} }
} }