25 lines
575 B
PHP
25 lines
575 B
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\validate\admin;
|
|
|
|
use app\service\util\CaptchaUtil;
|
|
use think\exception\ValidateException;
|
|
use think\Validate;
|
|
|
|
class LoginValidate extends Validate
|
|
{
|
|
protected $rule = [
|
|
'uuid|验证码uuid' => 'require',
|
|
'verify_code|验证码' => 'require|checkCode'
|
|
];
|
|
|
|
public function checkCode($value, $rule, $data = []): bool
|
|
{
|
|
if (!devAuth() && !CaptchaUtil::check($data['uuid'], $value)) {
|
|
throw new ValidateException("图形验证码错误");
|
|
}
|
|
return true;
|
|
}
|
|
}
|