mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Implemented PHP-CS-Fixer support
This commit is contained in:
@ -14,11 +14,11 @@ class AuthenticateData {
|
||||
$this->minecraftAccessKey = $minecraftAccessKey;
|
||||
}
|
||||
|
||||
public function getMinecraftAccessKey() : MinecraftAccessKey {
|
||||
public function getMinecraftAccessKey(): MinecraftAccessKey {
|
||||
return $this->minecraftAccessKey;
|
||||
}
|
||||
|
||||
public function getResponseData(bool $includeAvailableProfiles = false) : array {
|
||||
public function getResponseData(bool $includeAvailableProfiles = false): array {
|
||||
$accessKey = $this->minecraftAccessKey;
|
||||
$account = $accessKey->account;
|
||||
|
||||
|
@ -14,7 +14,9 @@ use common\models\MinecraftAccessKey;
|
||||
class AuthenticationForm extends ApiForm {
|
||||
|
||||
public $username;
|
||||
|
||||
public $password;
|
||||
|
||||
public $clientToken;
|
||||
|
||||
public function rules() {
|
||||
@ -41,13 +43,15 @@ class AuthenticationForm extends ApiForm {
|
||||
if (isset($errors['totp'])) {
|
||||
Authserver::error("User with login = '{$this->username}' protected by two factor auth.");
|
||||
throw new ForbiddenOperationException('Account protected with two factor auth.');
|
||||
} elseif (isset($errors['login'])) {
|
||||
}
|
||||
|
||||
if (isset($errors['login'])) {
|
||||
if ($errors['login'] === E::ACCOUNT_BANNED) {
|
||||
Authserver::error("User with login = '{$this->username}' is banned");
|
||||
throw new ForbiddenOperationException('This account has been suspended.');
|
||||
} else {
|
||||
Authserver::error("Cannot find user by login = '{$this->username}'");
|
||||
}
|
||||
|
||||
Authserver::error("Cannot find user by login = '{$this->username}'");
|
||||
} elseif (isset($errors['password'])) {
|
||||
Authserver::error("User with login = '{$this->username}' passed wrong password.");
|
||||
}
|
||||
@ -72,7 +76,7 @@ class AuthenticationForm extends ApiForm {
|
||||
return $dataModel;
|
||||
}
|
||||
|
||||
protected function createMinecraftAccessToken(Account $account) : MinecraftAccessKey {
|
||||
protected function createMinecraftAccessToken(Account $account): MinecraftAccessKey {
|
||||
/** @var MinecraftAccessKey|null $accessTokenModel */
|
||||
$accessTokenModel = MinecraftAccessKey::findOne([
|
||||
'account_id' => $account->id,
|
||||
@ -92,7 +96,7 @@ class AuthenticationForm extends ApiForm {
|
||||
return $accessTokenModel;
|
||||
}
|
||||
|
||||
protected function createLoginForm() : LoginForm {
|
||||
protected function createLoginForm(): LoginForm {
|
||||
return new LoginForm();
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ use common\models\MinecraftAccessKey;
|
||||
class InvalidateForm extends ApiForm {
|
||||
|
||||
public $accessToken;
|
||||
|
||||
public $clientToken;
|
||||
|
||||
public function rules() {
|
||||
@ -20,7 +21,7 @@ class InvalidateForm extends ApiForm {
|
||||
* @return bool
|
||||
* @throws \api\modules\authserver\exceptions\AuthserverException
|
||||
*/
|
||||
public function invalidateToken() : bool {
|
||||
public function invalidateToken(): bool {
|
||||
$this->validate();
|
||||
|
||||
$token = MinecraftAccessKey::findOne([
|
||||
|
@ -10,6 +10,7 @@ use common\models\MinecraftAccessKey;
|
||||
class RefreshTokenForm extends ApiForm {
|
||||
|
||||
public $accessToken;
|
||||
|
||||
public $clientToken;
|
||||
|
||||
public function rules() {
|
||||
|
@ -12,6 +12,7 @@ use Yii;
|
||||
class SignoutForm extends ApiForm {
|
||||
|
||||
public $username;
|
||||
|
||||
public $password;
|
||||
|
||||
public function rules() {
|
||||
@ -20,7 +21,7 @@ class SignoutForm extends ApiForm {
|
||||
];
|
||||
}
|
||||
|
||||
public function signout() : bool {
|
||||
public function signout(): bool {
|
||||
$this->validate();
|
||||
|
||||
$loginForm = new LoginForm();
|
||||
|
@ -16,7 +16,7 @@ class ValidateForm extends ApiForm {
|
||||
];
|
||||
}
|
||||
|
||||
public function validateToken() : bool {
|
||||
public function validateToken(): bool {
|
||||
$this->validate();
|
||||
|
||||
/** @var MinecraftAccessKey|null $result */
|
||||
|
Reference in New Issue
Block a user