mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Интегрирован сбор метрик в sessionserver
This commit is contained in:
@@ -6,6 +6,7 @@ use api\modules\session\exceptions\IllegalArgumentException;
|
||||
use api\modules\session\models\protocols\HasJoinedInterface;
|
||||
use api\modules\session\Module as Session;
|
||||
use common\models\Account;
|
||||
use Yii;
|
||||
use yii\base\ErrorException;
|
||||
use yii\base\Model;
|
||||
|
||||
@@ -19,6 +20,7 @@ class HasJoinedForm extends Model {
|
||||
}
|
||||
|
||||
public function hasJoined(): Account {
|
||||
Yii::$app->statsd->inc('sessionserver.hasJoined.attempt');
|
||||
if (!$this->protocol->validate()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@@ -26,13 +28,12 @@ class HasJoinedForm extends Model {
|
||||
$serverId = $this->protocol->getServerId();
|
||||
$username = $this->protocol->getUsername();
|
||||
|
||||
Session::info(
|
||||
"Server with server_id = '{$serverId}' trying to verify has joined user with username = '{$username}'."
|
||||
);
|
||||
Session::info("Server with server_id = '{$serverId}' trying to verify has joined user with username = '{$username}'.");
|
||||
|
||||
$joinModel = SessionModel::find($username, $serverId);
|
||||
if ($joinModel === null) {
|
||||
Session::error("Not found join operation for username = '{$username}'.");
|
||||
Yii::$app->statsd->inc('sessionserver.hasJoined.fail_no_join');
|
||||
throw new ForbiddenOperationException('Invalid token.');
|
||||
}
|
||||
|
||||
@@ -42,9 +43,8 @@ class HasJoinedForm extends Model {
|
||||
throw new ErrorException('Account must exists');
|
||||
}
|
||||
|
||||
Session::info(
|
||||
"User with username = '{$username}' successfully verified by server with server_id = '{$serverId}'."
|
||||
);
|
||||
Session::info("User with username = '{$username}' successfully verified by server with server_id = '{$serverId}'.");
|
||||
Yii::$app->statsd->inc('sessionserver.hasJoined.success');
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
Reference in New Issue
Block a user