mirror of
https://github.com/elyby/accounts.git
synced 2024-11-26 16:52:02 +05:30
Фикс бага с повторным добавлением аккаунта в authserver
This commit is contained in:
parent
bafac25baf
commit
4b6bfa15ec
@ -80,6 +80,7 @@ class AuthenticationForm extends Form {
|
|||||||
$accessTokenModel->insert();
|
$accessTokenModel->insert();
|
||||||
} else {
|
} else {
|
||||||
$accessTokenModel->refreshPrimaryKeyValue();
|
$accessTokenModel->refreshPrimaryKeyValue();
|
||||||
|
$accessTokenModel->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $accessTokenModel;
|
return $accessTokenModel;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user