mirror of
https://github.com/elyby/accounts.git
synced 2024-12-29 16:40:25 +05:30
e2e31c3720
У EmailActivationFixture зафиксирован стандартный путь к файлу данных
34 lines
722 B
PHP
34 lines
722 B
PHP
<?php
|
|
namespace api\validators;
|
|
|
|
use common\models\EmailActivation;
|
|
use yii\validators\Validator;
|
|
|
|
class EmailActivationKeyValidator extends Validator {
|
|
|
|
public $notExist = 'error.key_not_exists';
|
|
|
|
public $expired = 'error.key_expire';
|
|
|
|
public function validateValue($value) {
|
|
if (($model = $this->findEmailActivationModel($value)) === null) {
|
|
return [$this->notExist, []];
|
|
}
|
|
|
|
if ($model->isExpired()) {
|
|
return [$this->expired, []];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* @param string $key
|
|
* @return null|EmailActivation
|
|
*/
|
|
protected function findEmailActivationModel($key) {
|
|
return EmailActivation::findOne($key);
|
|
}
|
|
|
|
}
|