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:
@@ -44,13 +44,13 @@ use const common\LATEST_RULES_VERSION;
|
||||
*/
|
||||
class Account extends ActiveRecord {
|
||||
|
||||
const STATUS_DELETED = -10;
|
||||
const STATUS_BANNED = -1;
|
||||
const STATUS_REGISTERED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
public const STATUS_DELETED = -10;
|
||||
public const STATUS_BANNED = -1;
|
||||
public const STATUS_REGISTERED = 0;
|
||||
public const STATUS_ACTIVE = 10;
|
||||
|
||||
const PASS_HASH_STRATEGY_OLD_ELY = 0;
|
||||
const PASS_HASH_STRATEGY_YII2 = 1;
|
||||
public const PASS_HASH_STRATEGY_OLD_ELY = 0;
|
||||
public const PASS_HASH_STRATEGY_YII2 = 1;
|
||||
|
||||
public static function tableName(): string {
|
||||
return '{{%accounts}}';
|
||||
@@ -67,10 +67,9 @@ class Account extends ActiveRecord {
|
||||
$passwordHashStrategy = $this->password_hash_strategy;
|
||||
}
|
||||
|
||||
switch($passwordHashStrategy) {
|
||||
switch ($passwordHashStrategy) {
|
||||
case self::PASS_HASH_STRATEGY_OLD_ELY:
|
||||
$hashedPass = UserPass::make($this->email, $password);
|
||||
return $hashedPass === $this->password_hash;
|
||||
return UserPass::make($this->email, $password) === $this->password_hash;
|
||||
|
||||
case self::PASS_HASH_STRATEGY_YII2:
|
||||
return Yii::$app->security->validatePassword($password, $this->password_hash);
|
||||
|
||||
@@ -28,10 +28,10 @@ use yii\helpers\ArrayHelper;
|
||||
*/
|
||||
class EmailActivation extends ActiveRecord {
|
||||
|
||||
const TYPE_REGISTRATION_EMAIL_CONFIRMATION = 0;
|
||||
const TYPE_FORGOT_PASSWORD_KEY = 1;
|
||||
const TYPE_CURRENT_EMAIL_CONFIRMATION = 2;
|
||||
const TYPE_NEW_EMAIL_CONFIRMATION = 3;
|
||||
public const TYPE_REGISTRATION_EMAIL_CONFIRMATION = 0;
|
||||
public const TYPE_FORGOT_PASSWORD_KEY = 1;
|
||||
public const TYPE_CURRENT_EMAIL_CONFIRMATION = 2;
|
||||
public const TYPE_NEW_EMAIL_CONFIRMATION = 3;
|
||||
|
||||
public static function tableName() {
|
||||
return '{{%email_activations}}';
|
||||
@@ -79,15 +79,15 @@ class EmailActivation extends ActiveRecord {
|
||||
throw new InvalidConfigException('Unexpected type');
|
||||
}
|
||||
|
||||
return new $classMap[$type];
|
||||
return new $classMap[$type]();
|
||||
}
|
||||
|
||||
public static function getClassMap() {
|
||||
return [
|
||||
self::TYPE_REGISTRATION_EMAIL_CONFIRMATION => confirmations\RegistrationConfirmation::class,
|
||||
self::TYPE_FORGOT_PASSWORD_KEY => confirmations\ForgotPassword::class,
|
||||
self::TYPE_CURRENT_EMAIL_CONFIRMATION => confirmations\CurrentEmailConfirmation::class,
|
||||
self::TYPE_NEW_EMAIL_CONFIRMATION => confirmations\NewEmailConfirmation::class,
|
||||
self::TYPE_FORGOT_PASSWORD_KEY => confirmations\ForgotPassword::class,
|
||||
self::TYPE_CURRENT_EMAIL_CONFIRMATION => confirmations\CurrentEmailConfirmation::class,
|
||||
self::TYPE_NEW_EMAIL_CONFIRMATION => confirmations\NewEmailConfirmation::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ use yii\db\ActiveRecord;
|
||||
*/
|
||||
class MinecraftAccessKey extends ActiveRecord {
|
||||
|
||||
const LIFETIME = 172800; // Ключ актуален в течение 2 дней
|
||||
public const LIFETIME = 172800; // Ключ актуален в течение 2 дней
|
||||
|
||||
public static function tableName(): string {
|
||||
return '{{%minecraft_access_keys}}';
|
||||
|
||||
@@ -11,6 +11,10 @@ class OauthScopeQuery {
|
||||
|
||||
private $owner;
|
||||
|
||||
public function __construct(array $scopes) {
|
||||
$this->scopes = $scopes;
|
||||
}
|
||||
|
||||
public function onlyPublic(): self {
|
||||
$this->internal = false;
|
||||
return $this;
|
||||
@@ -43,8 +47,4 @@ class OauthScopeQuery {
|
||||
}), 'value');
|
||||
}
|
||||
|
||||
public function __construct(array $scopes) {
|
||||
$this->scopes = $scopes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class Textures {
|
||||
}
|
||||
|
||||
public function getMinecraftResponse() {
|
||||
$response = [
|
||||
$response = [
|
||||
'name' => $this->account->username,
|
||||
'id' => str_replace('-', '', $this->account->uuid),
|
||||
'properties' => [
|
||||
@@ -54,9 +54,9 @@ class Textures {
|
||||
|
||||
if (!$encrypted) {
|
||||
return $array;
|
||||
} else {
|
||||
return static::encrypt($array);
|
||||
}
|
||||
|
||||
return static::encrypt($array);
|
||||
}
|
||||
|
||||
public function getTextures(): array {
|
||||
|
||||
@@ -45,7 +45,7 @@ class UsernameHistory extends ActiveRecord {
|
||||
* @param int $afterTime
|
||||
* @return UsernameHistory|null
|
||||
*/
|
||||
public function findNext(int $afterTime = null) /*: ?UsernameHistory*/ {
|
||||
public function findNext(int $afterTime = null): ?UsernameHistory {
|
||||
return self::find()
|
||||
->andWhere(['account_id' => $this->account_id])
|
||||
->andWhere(['>', 'applied_in', $afterTime ?: $this->applied_in])
|
||||
|
||||
@@ -13,7 +13,7 @@ class NewEmailConfirmation extends EmailActivation {
|
||||
public function behaviors() {
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
'expirationBehavior' => [
|
||||
'repeatTimeout' => 5 * 60,
|
||||
'repeatTimeout' => 5 * 60,
|
||||
],
|
||||
'dataBehavior' => [
|
||||
'class' => NewEmailConfirmationBehavior::class,
|
||||
|
||||
@@ -8,11 +8,11 @@ use common\behaviors\DataBehavior;
|
||||
*/
|
||||
class NewEmailConfirmationBehavior extends DataBehavior {
|
||||
|
||||
public function getNewEmail() : string {
|
||||
public function getNewEmail(): string {
|
||||
return $this->getKey('newEmail');
|
||||
}
|
||||
|
||||
public function setNewEmail(string $newEmail) {
|
||||
public function setNewEmail(string $newEmail): void {
|
||||
$this->setKey('newEmail', $newEmail);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user