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