mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавлена логика HasJoined для сервера авторизации Minecraft
Исправлена ошибка в JoinForm Добавлено базовое API для общения с сервером системы скинов
This commit is contained in:
@ -4,9 +4,12 @@ namespace api\modules\session\controllers;
|
||||
use api\controllers\ApiController;
|
||||
use api\modules\session\exceptions\ForbiddenOperationException;
|
||||
use api\modules\session\exceptions\SessionServerException;
|
||||
use api\modules\session\models\HasJoinedForm;
|
||||
use api\modules\session\models\JoinForm;
|
||||
use api\modules\session\models\protocols\LegacyJoin;
|
||||
use api\modules\session\models\protocols\ModernHasJoined;
|
||||
use api\modules\session\models\protocols\ModernJoin;
|
||||
use common\models\Textures;
|
||||
use Yii;
|
||||
use yii\web\Response;
|
||||
|
||||
@ -57,4 +60,38 @@ class SessionController extends ApiController {
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
public function actionHasJoined() {
|
||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
$data = Yii::$app->request->get();
|
||||
$protocol = new ModernHasJoined($data['username'] ?? '', $data['serverId'] ?? '');
|
||||
$hasJoinedForm = new HasJoinedForm($protocol);
|
||||
$account = $hasJoinedForm->hasJoined();
|
||||
$textures = new Textures($account);
|
||||
|
||||
return $textures->getMinecraftResponse();
|
||||
}
|
||||
|
||||
public function actionHasJoinedLegacy() {
|
||||
Yii::$app->response->format = Response::FORMAT_RAW;
|
||||
|
||||
$data = Yii::$app->request->get();
|
||||
$protocol = new ModernHasJoined($data['user'] ?? '', $data['serverId'] ?? '');
|
||||
$hasJoinedForm = new HasJoinedForm($protocol);
|
||||
try {
|
||||
$hasJoinedForm->hasJoined();
|
||||
} catch (SessionServerException $e) {
|
||||
Yii::$app->response->statusCode = $e->statusCode;
|
||||
if ($e instanceof ForbiddenOperationException) {
|
||||
$message = 'NO';
|
||||
} else {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
return 'YES';
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user