cmbYouku_Api/app/validate/admin/LoginValidate.php

25 lines
575 B
PHP
Raw Permalink Normal View History

2024-07-01 15:57:07 +08:00
<?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;
}
}