mirror of
https://github.com/elyby/accounts.git
synced 2025-01-28 14:32:05 +05:30
Добавлена защита от регистрации на сервисы 10-минутной почты
This commit is contained in:
parent
45b1f43d09
commit
479f633d3f
@ -3,6 +3,7 @@ namespace common\models;
|
|||||||
|
|
||||||
use common\components\UserPass;
|
use common\components\UserPass;
|
||||||
use damirka\JWT\UserTrait;
|
use damirka\JWT\UserTrait;
|
||||||
|
use Ely\Yii2\TempmailValidator;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\base\NotSupportedException;
|
use yii\base\NotSupportedException;
|
||||||
@ -72,6 +73,7 @@ class Account extends ActiveRecord implements IdentityInterface {
|
|||||||
[['email'], 'required', 'message' => 'error.email_required'],
|
[['email'], 'required', 'message' => 'error.email_required'],
|
||||||
[['email'], 'string', 'max' => 255, 'tooLong' => 'error.email_too_long'],
|
[['email'], 'string', 'max' => 255, 'tooLong' => 'error.email_too_long'],
|
||||||
[['email'], 'email', 'checkDNS' => true, 'enableIDN' => true, 'message' => 'error.email_invalid'],
|
[['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'],
|
[['email'], 'unique', 'message' => 'error.email_not_available'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
"yiisoft/yii2-redis": "~2.0.0",
|
"yiisoft/yii2-redis": "~2.0.0",
|
||||||
"damirka/yii2-jwt": "~0.1.0",
|
"damirka/yii2-jwt": "~0.1.0",
|
||||||
"guzzlehttp/guzzle": "~5.3.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": {
|
"require-dev": {
|
||||||
"yiisoft/yii2-codeception": "*",
|
"yiisoft/yii2-codeception": "*",
|
||||||
|
@ -103,6 +103,12 @@ class AccountTest extends DbTestCase {
|
|||||||
expect($model->getErrors('email'))->equals(['error.email_invalid']);
|
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() {
|
$this->specify('email should be unique', function() {
|
||||||
$model = new Account(['email' => $this->accounts['admin']['email']]);
|
$model = new Account(['email' => $this->accounts['admin']['email']]);
|
||||||
expect($model->validate('email'))->false();
|
expect($model->validate('email'))->false();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user