Упразднён контроллер PasswordProtectedController и заменён на валидатор PasswordRequiredValidator

Реорганизованы тесты для ChangeUsernameFormTest
This commit is contained in:
ErickSkrauch
2016-07-25 14:07:14 +03:00
parent a4dad11be5
commit 31679b84cb
9 changed files with 121 additions and 105 deletions

View File

@@ -1,7 +1,8 @@
<?php
namespace api\models\profile\ChangeEmail;
use api\models\base\PasswordProtectedForm;
use api\models\base\ApiForm;
use api\validators\PasswordRequiredValidator;
use common\helpers\Error as E;
use common\models\Account;
use common\models\confirmations\CurrentEmailConfirmation;
@@ -11,10 +12,12 @@ use yii\base\ErrorException;
use yii\base\Exception;
use yii\base\InvalidConfigException;
class InitStateForm extends PasswordProtectedForm {
class InitStateForm extends ApiForm {
public $email;
public $password;
private $account;
public function __construct(Account $account, array $config = []) {
@@ -28,9 +31,10 @@ class InitStateForm extends PasswordProtectedForm {
}
public function rules() {
return array_merge(parent::rules(), [
return [
['email', 'validateFrequency'],
]);
['password', PasswordRequiredValidator::class, 'account' => $this->account],
];
}
public function validateFrequency($attribute) {
@@ -90,7 +94,6 @@ class InitStateForm extends PasswordProtectedForm {
}
public function sendCode(EmailActivation $code) {
/** @var \yii\swiftmailer\Mailer $mailer */
$mailer = Yii::$app->mailer;
$fromEmail = Yii::$app->params['fromEmail'];
if (!$fromEmail) {
@@ -98,7 +101,6 @@ class InitStateForm extends PasswordProtectedForm {
}
$acceptor = $code->account;
/** @var \yii\swiftmailer\Message $message */
$message = $mailer->compose([
'html' => '@app/mails/current-email-confirmation-html',
'text' => '@app/mails/current-email-confirmation-text',