diff --git a/api/validators/PasswordRequiredValidator.php b/api/validators/PasswordRequiredValidator.php index bfdf6e3..af3161d 100644 --- a/api/validators/PasswordRequiredValidator.php +++ b/api/validators/PasswordRequiredValidator.php @@ -36,7 +36,7 @@ class PasswordRequiredValidator extends Validator { } if ($this->account->validatePassword($value) === false) { - return [E::PASSWORD_INVALID, []]; + return [E::PASSWORD_INCORRECT, []]; } return null; diff --git a/common/helpers/Error.php b/common/helpers/Error.php index fb3fb7b..e398b9a 100644 --- a/common/helpers/Error.php +++ b/common/helpers/Error.php @@ -20,14 +20,6 @@ final class Error { const LOGIN_NOT_EXIST = 'error.login_not_exist'; const PASSWORD_REQUIRED = 'error.password_required'; - const PASSWORD_INVALID = 'error.password_invalid'; - /** - * TODO: На фронте с password_incorrect и password_invalid возникла неувязочка. - * Один возникает у формы входа и там уместно предлагать восстановление пароля. - * Другой возникает у паролезащищённой формы и там уже ничего предлагать не нужно. - * Но по факту это ведь одна и та же ошибка. - * @deprecated - */ const PASSWORD_INCORRECT = 'error.password_incorrect'; const PASSWORD_TOO_SHORT = 'error.password_too_short'; diff --git a/tests/codeception/api/unit/validators/PasswordRequiredValidatorTest.php b/tests/codeception/api/unit/validators/PasswordRequiredValidatorTest.php index 471c7ab..cdbcbc5 100644 --- a/tests/codeception/api/unit/validators/PasswordRequiredValidatorTest.php +++ b/tests/codeception/api/unit/validators/PasswordRequiredValidatorTest.php @@ -6,6 +6,7 @@ use Codeception\Specify; use common\models\Account; use tests\codeception\api\unit\DbTestCase; use tests\codeception\common\_support\ProtectedCaller; +use common\helpers\Error as E; class PasswordRequiredValidatorTest extends DbTestCase { use Specify; @@ -15,12 +16,12 @@ class PasswordRequiredValidatorTest extends DbTestCase { $account = new Account(['password' => '12345678']); $this->specify('get error.password_required if password is empty', function () use ($account) { $model = new PasswordRequiredValidator(['account' => $account]); - expect($this->callProtected($model, 'validateValue', ''))->equals(['error.password_required', []]); + expect($this->callProtected($model, 'validateValue', ''))->equals([E::PASSWORD_REQUIRED, []]); }); - $this->specify('get error.password_invalid if password is incorrect', function () use ($account) { + $this->specify('get error.password_incorrect if password is incorrect', function () use ($account) { $model = new PasswordRequiredValidator(['account' => $account]); - expect($this->callProtected($model, 'validateValue', '87654321'))->equals(['error.password_invalid', []]); + expect($this->callProtected($model, 'validateValue', '87654321'))->equals([E::PASSWORD_INCORRECT, []]); }); $this->specify('no errors, if password is correct for provided account', function () use ($account) {