From 479f633d3f96a4e777a87148b18e3cf20a1e99ac Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sun, 1 May 2016 19:43:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=82=20=D1=80=D0=B5=D0=B3=D0=B8=D1=81=D1=82=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BD=D0=B0=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8?= =?UTF-8?q?=D1=81=D1=8B=2010-=D0=BC=D0=B8=D0=BD=D1=83=D1=82=D0=BD=D0=BE?= =?UTF-8?q?=D0=B9=20=D0=BF=D0=BE=D1=87=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/models/Account.php | 2 ++ composer.json | 3 ++- tests/codeception/common/unit/models/AccountTest.php | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/models/Account.php b/common/models/Account.php index 094698a..73a98ea 100644 --- a/common/models/Account.php +++ b/common/models/Account.php @@ -3,6 +3,7 @@ namespace common\models; use common\components\UserPass; use damirka\JWT\UserTrait; +use Ely\Yii2\TempmailValidator; use Yii; use yii\base\InvalidConfigException; use yii\base\NotSupportedException; @@ -72,6 +73,7 @@ class Account extends ActiveRecord implements IdentityInterface { [['email'], 'required', 'message' => 'error.email_required'], [['email'], 'string', 'max' => 255, 'tooLong' => 'error.email_too_long'], [['email'], 'email', 'checkDNS' => true, 'enableIDN' => true, 'message' => 'error.email_invalid'], + [['email'], TempmailValidator::class, 'message' => 'error.email_is_tempmail'], [['email'], 'unique', 'message' => 'error.email_not_available'], ]; } diff --git a/composer.json b/composer.json index e7dcb0f..e3b2455 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "yiisoft/yii2-redis": "~2.0.0", "damirka/yii2-jwt": "~0.1.0", "guzzlehttp/guzzle": "~5.3.0", - "php-amqplib/php-amqplib": "~2.6.2" + "php-amqplib/php-amqplib": "~2.6.2", + "ely/yii2-tempmail-validator": "~1.0.0" }, "require-dev": { "yiisoft/yii2-codeception": "*", diff --git a/tests/codeception/common/unit/models/AccountTest.php b/tests/codeception/common/unit/models/AccountTest.php index d6005d5..3dbaad9 100644 --- a/tests/codeception/common/unit/models/AccountTest.php +++ b/tests/codeception/common/unit/models/AccountTest.php @@ -103,6 +103,12 @@ class AccountTest extends DbTestCase { expect($model->getErrors('email'))->equals(['error.email_invalid']); }); + $this->specify('email should be not tempmail', function() { + $model = new Account(['email' => 'c1414001@trbvn.com']); + expect($model->validate(['email']))->false(); + expect($model->getErrors('email'))->equals(['error.email_is_tempmail']); + }); + $this->specify('email should be unique', function() { $model = new Account(['email' => $this->accounts['admin']['email']]); expect($model->validate('email'))->false();