mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Перенесена логика join операции для современных серверов.
Нужно признать, что перенесена она так себе, но в будущем я обязательно это перепишу.
This commit is contained in:
@@ -53,8 +53,8 @@ class MinecraftAccessKey extends ActiveRecord {
|
||||
return $this->hasOne(Account::class, ['id' => 'account_id']);
|
||||
}
|
||||
|
||||
public function isActual() : bool {
|
||||
return $this->updated_at + self::LIFETIME >= time();
|
||||
public function isExpired() : bool {
|
||||
return time() > $this->updated_at + self::LIFETIME;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ class OauthAccessToken extends ActiveRecord {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isExpired() {
|
||||
public function isExpired() : bool {
|
||||
return time() > $this->expire_time;
|
||||
}
|
||||
|
||||
|
23
common/validators/UuidValidator.php
Normal file
23
common/validators/UuidValidator.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace common\validators;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use yii\validators\Validator;
|
||||
|
||||
class UuidValidator extends Validator {
|
||||
|
||||
public $skipOnEmpty = false;
|
||||
|
||||
public $message = '{attribute} must be valid uuid';
|
||||
|
||||
public function validateAttribute($model, $attribute) {
|
||||
try {
|
||||
$uuid = Uuid::fromString($model->$attribute)->toString();
|
||||
$model->$attribute = $uuid;
|
||||
} catch (InvalidArgumentException $e) {
|
||||
$this->addError($model, $attribute, $this->message, []);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user