mirror of
https://github.com/elyby/accounts.git
synced 2024-11-09 23:12:20 +05:30
Убраны разрознености в ошибках, скорреткированы тесты
This commit is contained in:
parent
73d07f355a
commit
4614cf8fe7
@ -69,7 +69,7 @@ class AuthenticationController extends Controller {
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
|
||||
if (ArrayHelper::getValue($data['errors'], 'login') === 'error.email_frequency') {
|
||||
if (ArrayHelper::getValue($data['errors'], 'login') === 'error.recently_sent_message') {
|
||||
$emailActivation = $model->getEmailActivation();
|
||||
$data['data'] = [
|
||||
'canRepeatIn' => $emailActivation->canRepeatIn(),
|
||||
|
@ -46,7 +46,7 @@ class ForgotPasswordForm extends ApiForm {
|
||||
if (!$this->hasErrors()) {
|
||||
$emailConfirmation = $this->getEmailActivation();
|
||||
if ($emailConfirmation !== null && !$emailConfirmation->canRepeat()) {
|
||||
$this->addError($attribute, 'error.email_frequency');
|
||||
$this->addError($attribute, 'error.recently_sent_message');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class RegistrationForm extends ApiForm {
|
||||
public function rules() {
|
||||
return [
|
||||
[[], ReCaptchaValidator::class, 'message' => 'error.captcha_invalid', 'when' => !YII_ENV_TEST],
|
||||
['rulesAgreement', 'required', 'message' => 'error.you_must_accept_rules'],
|
||||
['rulesAgreement', 'required', 'message' => 'error.rulesAgreement_required'],
|
||||
|
||||
['username', 'validateUsername', 'skipOnEmpty' => false],
|
||||
['email', 'validateEmail', 'skipOnEmpty' => false],
|
||||
|
@ -13,7 +13,7 @@ class KeyConfirmationForm extends ApiForm {
|
||||
public function rules() {
|
||||
return [
|
||||
// TODO: нужно провалидировать количество попыток ввода кода для определённого IP адреса и в случае чего запросить капчу
|
||||
['key', 'required', 'message' => 'error.key_is_required'],
|
||||
['key', 'required', 'message' => 'error.key_required'],
|
||||
['key', EmailActivationKeyValidator::class],
|
||||
];
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class EmailConfirmationCest {
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
'key' => 'error.key_is_required',
|
||||
'key' => 'error.key_required',
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -39,7 +39,7 @@ class ForgotPasswordCest {
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
'login' => 'error.email_frequency',
|
||||
'login' => 'error.recently_sent_message',
|
||||
],
|
||||
]);
|
||||
$I->canSeeResponseJsonMatchesJsonPath('$.data.canRepeatIn');
|
||||
|
@ -18,7 +18,7 @@ class RegisterCest {
|
||||
public function testIncorrectRegistration(FunctionalTester $I) {
|
||||
$route = new SignupRoute($I);
|
||||
|
||||
$I->wantTo('get error.you_must_accept_rules if we don\'t accept rules');
|
||||
$I->wantTo('get error.rulesAgreement_required if we don\'t accept rules');
|
||||
$route->register([
|
||||
'username' => 'ErickSkrauch',
|
||||
'email' => 'erickskrauch@ely.by',
|
||||
@ -28,17 +28,17 @@ class RegisterCest {
|
||||
$I->canSeeResponseContainsJson([
|
||||
'success' => false,
|
||||
'errors' => [
|
||||
'rulesAgreement' => 'error.you_must_accept_rules',
|
||||
'rulesAgreement' => 'error.rulesAgreement_required',
|
||||
],
|
||||
]);
|
||||
|
||||
$I->wantTo('don\'t see error.you_must_accept_rules if we accept rules');
|
||||
$I->wantTo('don\'t see error.rulesAgreement_requireds if we accept rules');
|
||||
$route->register([
|
||||
'rulesAgreement' => true,
|
||||
]);
|
||||
$I->cantSeeResponseContainsJson([
|
||||
'errors' => [
|
||||
'rulesAgreement' => 'error.you_must_accept_rules',
|
||||
'rulesAgreement' => 'error.rulesAgreement_required',
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -79,7 +79,7 @@ class ForgotPasswordFormTest extends DbTestCase {
|
||||
]);
|
||||
|
||||
$model->validateFrequency('login');
|
||||
expect($model->getErrors('login'))->equals(['error.email_frequency']);
|
||||
expect($model->getErrors('login'))->equals(['error.recently_sent_message']);
|
||||
});
|
||||
|
||||
$this->specify('empty errors if email was sent a long time ago', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user