| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace App\Module\User\Validation;
- use App\Module\App\Validator\NoLogin;
- use App\Module\Common\Validator\Phone;
- use App\Module\Sms\Validator\PhoneCode;
- use App\Module\Sys\ContinuousTimes;
- use App\Module\Ulogic\Validator\Model2Unit;
- use App\Module\User\Models\User;
- use App\Module\User\Validator\AutoRegPhone;
- use App\Module\User\Validator\CanLogin;
- use App\Module\User\Validator\LoginJizhi;
- use App\Module\User\Validator\PhoneContinuousTimes;
- use UCore\ValidationCore;
- /**
- * 登录验证器
- *
- */
- class Login4Phone extends ValidationCore
- {
- protected string $name = 'login';
- /**
- * @var User
- */
- public $user;
- /**
- * @var \App\Module\Ulogic\Unit\User
- */
- public $userLogic;
- public function rules($rules = []): array
- {
- $rules = [
- [
- 'phone,code', 'required'
- ],
- [
- 'phone',
- new \App\Module\Common\Validator\Phone($this),
- 'msg' => '不存在的手机号码'
- ],
- [
- 'code', new PhoneCode($this, ['login', 'phone']),
- 'msg' => '短信验证码错误'
- ],
- [
- 'phone', new AutoRegPhone($this, ['user']),
- 'msg' => '手机号码不可用'
- ],
- [
- 'phone',
- new CanLogin($this),
- 'msg' => '不能登录'
- ],
- [
- 'phone',new NoLogin($this),
- 'msg'=>'重复的登陆,请清空应用储存数据或重新安装后重试'
- ],
- [
- 'phone',
- new Model2Unit($this, ['user', 'userLogic']),
- 'msg' => ''
- ]
- ];
- // 错误次数验证
- $v = new PhoneContinuousTimes($this);
- array_unshift($rules,[
- 'phone',$v,
- 'msg'=>'登录错误过多,限制登录'
- ]);
- $this->addConsumeErrorValidator($v);
- // 登录封禁
- $loginJIn = new LoginJizhi($this);
- array_unshift($rules,[
- 'phone',$loginJIn,
- 'msg'=>'登录错误过多,限制登录12小时'
- ]);
- return parent::rules($rules);
- }
- }
|