mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Cleanup session server module
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace api\modules\session\models;
|
||||
|
||||
use api\modules\session\exceptions\ForbiddenOperationException;
|
||||
@@ -6,19 +8,27 @@ 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 Webmozart\Assert\Assert;
|
||||
use Yii;
|
||||
use yii\base\ErrorException;
|
||||
use yii\base\Model;
|
||||
|
||||
class HasJoinedForm extends Model {
|
||||
|
||||
/**
|
||||
* @var HasJoinedInterface
|
||||
*/
|
||||
private $protocol;
|
||||
|
||||
public function __construct(HasJoinedInterface $protocol, array $config = []) {
|
||||
$this->protocol = $protocol;
|
||||
parent::__construct($config);
|
||||
$this->protocol = $protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Account
|
||||
* @throws ForbiddenOperationException
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public function hasJoined(): Account {
|
||||
Yii::$app->statsd->inc('sessionserver.hasJoined.attempt');
|
||||
if (!$this->protocol->validate()) {
|
||||
@@ -38,10 +48,9 @@ class HasJoinedForm extends Model {
|
||||
}
|
||||
|
||||
$joinModel->delete();
|
||||
/** @var Account $account */
|
||||
$account = $joinModel->getAccount();
|
||||
if ($account === null) {
|
||||
throw new ErrorException('Account must exists');
|
||||
}
|
||||
Assert::notNull($account);
|
||||
|
||||
Session::info("User with username = '{$username}' successfully verified by server with server_id = '{$serverId}'.");
|
||||
Yii::$app->statsd->inc('sessionserver.hasJoined.success');
|
||||
|
||||
Reference in New Issue
Block a user