mirror of
https://github.com/elyby/accounts.git
synced 2024-12-23 13:50:06 +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();
|
||||
}
|
||||
|
||||
$clients = $account->oauthClients;
|
||||
/** @var OauthClient[] $clients */
|
||||
$clients = $account->getOauthClients()->orderBy(['created_at' => SORT_ASC])->all();
|
||||
$result = array_map(function(OauthClient $client) {
|
||||
return $this->formatClient($client);
|
||||
}, $clients);
|
||||
@ -152,13 +153,13 @@ class ClientsController extends Controller {
|
||||
'name' => $client->name,
|
||||
'websiteUrl' => $client->website_url,
|
||||
'createdAt' => $client->created_at,
|
||||
'countUsers' => (int)$client->getSessions()->count(),
|
||||
];
|
||||
|
||||
switch ($client->type) {
|
||||
case OauthClient::TYPE_APPLICATION:
|
||||
$result['description'] = $client->description;
|
||||
$result['redirectUri'] = $client->redirect_uri;
|
||||
$result['countUsers'] = (int)$client->getSessions()->count();
|
||||
break;
|
||||
case OauthClient::TYPE_MINECRAFT_SERVER:
|
||||
$result['minecraftServerIp'] = $client->minecraft_server_ip;
|
||||
|
@ -38,7 +38,7 @@ class OauthClientOwner extends Rule {
|
||||
/** @var OauthClient|null $client */
|
||||
$client = OauthClient::findOne($clientId);
|
||||
if ($client === null) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
$identity = Yii::$app->user->findIdentityByAccessToken($accessToken);
|
||||
|
@ -42,7 +42,7 @@ class OauthClientOwnerTest extends TestCase {
|
||||
|
||||
$this->assertFalse($rule->execute('token', $item, []));
|
||||
$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;
|
||||
$this->assertFalse($rule->execute('token', $item, ['clientId' => 'admin-oauth-client']));
|
||||
$item->name = P::VIEW_OWN_OAUTH_CLIENTS;
|
||||
|
Loading…
Reference in New Issue
Block a user