mirror of
https://github.com/elyby/accounts.git
synced 2024-11-30 02:32:26 +05:30
Убран валидатор на тип алгоритма хэширования пароля для формы инициализации смены E-mail адреса
This commit is contained in:
parent
fe2c422621
commit
b5ed01853e
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace api\models\profile\ChangeEmail;
|
||||
|
||||
use api\models\base\PasswordProtectedForm;
|
||||
use common\models\Account;
|
||||
use common\models\confirmations\CurrentEmailConfirmation;
|
||||
use common\models\EmailActivation;
|
||||
@ -9,7 +10,7 @@ use yii\base\ErrorException;
|
||||
use yii\base\Exception;
|
||||
use yii\base\InvalidConfigException;
|
||||
|
||||
class InitStateForm extends \api\models\base\PasswordProtectedForm {
|
||||
class InitStateForm extends PasswordProtectedForm {
|
||||
|
||||
public $email;
|
||||
|
||||
@ -27,15 +28,8 @@ class InitStateForm extends \api\models\base\PasswordProtectedForm {
|
||||
public function rules() {
|
||||
// TODO: поверить наличие уже отправленных подтверждений смены E-mail
|
||||
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() {
|
||||
|
@ -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() {
|
||||
$this->specify('create valid code and store it to database', function() {
|
||||
/** @var Account $account */
|
||||
|
Loading…
Reference in New Issue
Block a user