#148: remove depreacted error.password_required

This commit is contained in:
SleepWalker 2016-07-28 07:44:16 +03:00
parent d514ba620d
commit 327e900f2b
3 changed files with 5 additions and 12 deletions

View File

@ -36,7 +36,7 @@ class PasswordRequiredValidator extends Validator {
}
if ($this->account->validatePassword($value) === false) {
return [E::PASSWORD_INVALID, []];
return [E::PASSWORD_INCORRECT, []];
}
return null;

View File

@ -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';

View File

@ -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) {