2016-01-21 02:44:29 +05:30
|
|
|
<?php
|
2016-03-20 05:03:49 +05:30
|
|
|
namespace api\models\base;
|
2016-01-21 02:44:29 +05:30
|
|
|
|
2016-06-17 02:02:23 +05:30
|
|
|
use common\helpers\Error as E;
|
2016-05-15 04:03:21 +05:30
|
|
|
use api\validators\EmailActivationKeyValidator;
|
2016-01-21 02:44:29 +05:30
|
|
|
use common\models\EmailActivation;
|
|
|
|
|
2016-03-20 05:03:49 +05:30
|
|
|
class KeyConfirmationForm extends ApiForm {
|
2016-01-21 02:44:29 +05:30
|
|
|
|
|
|
|
public $key;
|
|
|
|
|
|
|
|
private $model;
|
|
|
|
|
|
|
|
public function rules() {
|
|
|
|
return [
|
2016-03-13 04:49:00 +05:30
|
|
|
// TODO: нужно провалидировать количество попыток ввода кода для определённого IP адреса и в случае чего запросить капчу
|
2016-06-17 02:02:23 +05:30
|
|
|
['key', 'required', 'message' => E::KEY_REQUIRED],
|
2016-05-15 04:03:21 +05:30
|
|
|
['key', EmailActivationKeyValidator::class],
|
2016-01-21 02:44:29 +05:30
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EmailActivation|null
|
|
|
|
*/
|
|
|
|
public function getActivationCodeModel() {
|
|
|
|
if ($this->model === null) {
|
|
|
|
$this->model = EmailActivation::findOne($this->key);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->model;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|