Убран валидатор на тип алгоритма хэширования пароля для формы инициализации смены E-mail адреса

This commit is contained in:
ErickSkrauch 2016-05-23 22:55:36 +03:00
parent fe2c422621
commit b5ed01853e
2 changed files with 3 additions and 27 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
namespace api\models\profile\ChangeEmail; namespace api\models\profile\ChangeEmail;
use api\models\base\PasswordProtectedForm;
use common\models\Account; use common\models\Account;
use common\models\confirmations\CurrentEmailConfirmation; use common\models\confirmations\CurrentEmailConfirmation;
use common\models\EmailActivation; use common\models\EmailActivation;
@ -9,7 +10,7 @@ use yii\base\ErrorException;
use yii\base\Exception; use yii\base\Exception;
use yii\base\InvalidConfigException; use yii\base\InvalidConfigException;
class InitStateForm extends \api\models\base\PasswordProtectedForm { class InitStateForm extends PasswordProtectedForm {
public $email; public $email;
@ -27,15 +28,8 @@ class InitStateForm extends \api\models\base\PasswordProtectedForm {
public function rules() { public function rules() {
// TODO: поверить наличие уже отправленных подтверждений смены E-mail // TODO: поверить наличие уже отправленных подтверждений смены E-mail
return array_merge(parent::rules(), [ return array_merge(parent::rules(), [
['!email', 'validateAccountPasswordHashStrategy', 'skipOnEmpty' => false],
]);
}
public function validateAccountPasswordHashStrategy($attribute) { ]);
$account = $this->getAccount();
if ($account->password_hash_strategy === Account::PASS_HASH_STRATEGY_OLD_ELY) {
$this->addError($attribute, 'error.old_hash_strategy');
}
} }
public function sendCurrentEmailConfirmation() { public function sendCurrentEmailConfirmation() {

View File

@ -45,24 +45,6 @@ class InitStateFormTest extends DbTestCase {
]; ];
} }
public function testValidateAccountPasswordHashStrategy() {
$this->specify('we cannot change password on old password hash strategy', function() {
$account = new Account();
$account->password_hash_strategy = Account::PASS_HASH_STRATEGY_OLD_ELY;
$model = new InitStateForm($account);
$model->validateAccountPasswordHashStrategy('email');
expect($model->getErrors('email'))->equals(['error.old_hash_strategy']);
});
$this->specify('no errors on modern password hash strategy', function() {
$account = new Account();
$account->password_hash_strategy = Account::PASS_HASH_STRATEGY_YII2;
$model = new InitStateForm($account);
$model->validateAccountPasswordHashStrategy('email');
expect($model->getErrors('email'))->isEmpty();
});
}
public function testCreateCode() { public function testCreateCode() {
$this->specify('create valid code and store it to database', function() { $this->specify('create valid code and store it to database', function() {
/** @var Account $account */ /** @var Account $account */