mirror of
https://github.com/elyby/accounts.git
synced 2024-12-23 22:00:06 +05:30
Fix incorrect response in case when user's profile for provided UUID can't be found
This commit is contained in:
parent
0c2832f95f
commit
c64f386365
@ -110,11 +110,10 @@ class SessionController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @param string $uuid
|
* @param string $uuid
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array|null
|
||||||
* @throws ForbiddenOperationException
|
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
*/
|
*/
|
||||||
public function actionProfile(string $uuid): array {
|
public function actionProfile(string $uuid): ?array {
|
||||||
try {
|
try {
|
||||||
$uuid = Uuid::fromString($uuid)->toString();
|
$uuid = Uuid::fromString($uuid)->toString();
|
||||||
} catch (\InvalidArgumentException $e) {
|
} catch (\InvalidArgumentException $e) {
|
||||||
@ -124,7 +123,8 @@ class SessionController extends Controller {
|
|||||||
/** @var Account|null $account */
|
/** @var Account|null $account */
|
||||||
$account = Account::find()->excludeDeleted()->andWhere(['uuid' => $uuid])->one();
|
$account = Account::find()->excludeDeleted()->andWhere(['uuid' => $uuid])->one();
|
||||||
if ($account === null) {
|
if ($account === null) {
|
||||||
throw new ForbiddenOperationException('Invalid uuid.');
|
Yii::$app->response->setStatusCode(204);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (new Textures($account))->getMinecraftResponse();
|
return (new Textures($account))->getMinecraftResponse();
|
||||||
|
@ -49,24 +49,14 @@ class ProfileCest {
|
|||||||
public function getProfileWithNonexistentUuid(FunctionalTester $I) {
|
public function getProfileWithNonexistentUuid(FunctionalTester $I) {
|
||||||
$I->wantTo('get info about nonexistent uuid');
|
$I->wantTo('get info about nonexistent uuid');
|
||||||
$this->route->profile(v4());
|
$this->route->profile(v4());
|
||||||
$I->canSeeResponseCodeIs(401);
|
$I->canSeeResponseCodeIs(204);
|
||||||
$I->canSeeResponseIsJson();
|
$I->canSeeResponseEquals('');
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->canSeeResponseContainsJson([
|
|
||||||
'error' => 'ForbiddenOperationException',
|
|
||||||
'errorMessage' => 'Invalid uuid.',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getProfileOfAccountMarkedForDeletion(FunctionalTester $I) {
|
public function getProfileOfAccountMarkedForDeletion(FunctionalTester $I) {
|
||||||
$this->route->profile('6383de63-8f85-4ed5-92b7-5401a1fa68cd');
|
$this->route->profile('6383de63-8f85-4ed5-92b7-5401a1fa68cd');
|
||||||
$I->canSeeResponseCodeIs(401);
|
$I->canSeeResponseCodeIs(204);
|
||||||
$I->canSeeResponseIsJson();
|
$I->canSeeResponseEquals('');
|
||||||
$I->seeResponseIsJson();
|
|
||||||
$I->canSeeResponseContainsJson([
|
|
||||||
'error' => 'ForbiddenOperationException',
|
|
||||||
'errorMessage' => 'Invalid uuid.',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user