mirror of
https://github.com/elyby/accounts.git
synced 2025-02-03 09:19:39 +05:30
Fix 403 error on not exists application.
Remove countUsers from minecraft server application type.
This commit is contained in:
parent
f3f53e752d
commit
4ee8544355
@ -136,7 +136,8 @@ class ClientsController extends Controller {
|
|||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$clients = $account->oauthClients;
|
/** @var OauthClient[] $clients */
|
||||||
|
$clients = $account->getOauthClients()->orderBy(['created_at' => SORT_ASC])->all();
|
||||||
$result = array_map(function(OauthClient $client) {
|
$result = array_map(function(OauthClient $client) {
|
||||||
return $this->formatClient($client);
|
return $this->formatClient($client);
|
||||||
}, $clients);
|
}, $clients);
|
||||||
@ -152,13 +153,13 @@ class ClientsController extends Controller {
|
|||||||
'name' => $client->name,
|
'name' => $client->name,
|
||||||
'websiteUrl' => $client->website_url,
|
'websiteUrl' => $client->website_url,
|
||||||
'createdAt' => $client->created_at,
|
'createdAt' => $client->created_at,
|
||||||
'countUsers' => (int)$client->getSessions()->count(),
|
|
||||||
];
|
];
|
||||||
|
|
||||||
switch ($client->type) {
|
switch ($client->type) {
|
||||||
case OauthClient::TYPE_APPLICATION:
|
case OauthClient::TYPE_APPLICATION:
|
||||||
$result['description'] = $client->description;
|
$result['description'] = $client->description;
|
||||||
$result['redirectUri'] = $client->redirect_uri;
|
$result['redirectUri'] = $client->redirect_uri;
|
||||||
|
$result['countUsers'] = (int)$client->getSessions()->count();
|
||||||
break;
|
break;
|
||||||
case OauthClient::TYPE_MINECRAFT_SERVER:
|
case OauthClient::TYPE_MINECRAFT_SERVER:
|
||||||
$result['minecraftServerIp'] = $client->minecraft_server_ip;
|
$result['minecraftServerIp'] = $client->minecraft_server_ip;
|
||||||
|
@ -38,7 +38,7 @@ class OauthClientOwner extends Rule {
|
|||||||
/** @var OauthClient|null $client */
|
/** @var OauthClient|null $client */
|
||||||
$client = OauthClient::findOne($clientId);
|
$client = OauthClient::findOne($clientId);
|
||||||
if ($client === null) {
|
if ($client === null) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$identity = Yii::$app->user->findIdentityByAccessToken($accessToken);
|
$identity = Yii::$app->user->findIdentityByAccessToken($accessToken);
|
||||||
|
@ -42,7 +42,7 @@ class OauthClientOwnerTest extends TestCase {
|
|||||||
|
|
||||||
$this->assertFalse($rule->execute('token', $item, []));
|
$this->assertFalse($rule->execute('token', $item, []));
|
||||||
$this->assertTrue($rule->execute('token', $item, ['clientId' => 'admin-oauth-client']));
|
$this->assertTrue($rule->execute('token', $item, ['clientId' => 'admin-oauth-client']));
|
||||||
$this->assertFalse($rule->execute('token', $item, ['clientId' => 'not-exists-client']));
|
$this->assertTrue($rule->execute('token', $item, ['clientId' => 'not-exists-client']));
|
||||||
$account->id = 2;
|
$account->id = 2;
|
||||||
$this->assertFalse($rule->execute('token', $item, ['clientId' => 'admin-oauth-client']));
|
$this->assertFalse($rule->execute('token', $item, ['clientId' => 'admin-oauth-client']));
|
||||||
$item->name = P::VIEW_OWN_OAUTH_CLIENTS;
|
$item->name = P::VIEW_OWN_OAUTH_CLIENTS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user