feat: 代理登录/注册改图形数字验证码(SVG无GD依赖、一次性校验);后台内容区全屏铺满

This commit is contained in:
root committed 2026-10-21 15:04:43 +08:00
1 parent 423ac0d3b5
commit d5a3183895
10 files changed
+272 -71

No files matched your search

+16 -9
View File
@@ -7,6 +7,7 @@ use App\Core\Database;
use App\Core\Validator;
use App\Services\JwtService;
use App\Services\TurnstileService;
use App\Services\CaptchaService;
/**
* 认证控制器
@@ -53,11 +54,17 @@ class AuthController extends Controller
$this->error('请输入用户名或邮箱');
}
// Cloudflare Turnstile(按系统配置开关与入口白名单)
$portalKey = $portal === 'agent' ? 'agent_login' : 'admin_login';
$turnstileToken = trim((string) ($input['turnstile_token'] ?? ''));
if (!TurnstileService::verifyFor($portalKey, $turnstileToken !== '' ? $turnstileToken : null, clientIp())) {
$this->error('人机验证失败,请完成验证后重试');
// 人机验证:代理入口用图形数字验证码,管理员入口用 Cloudflare Turnstile(按配置开关)
if ($portal === 'agent') {
$captchaCode = trim((string) ($input['captcha_code'] ?? ''));
if (!CaptchaService::verify($captchaCode)) {
$this->error('图形验证码错误或已过期,请刷新后重试');
}
} else {
$turnstileToken = trim((string) ($input['turnstile_token'] ?? ''));
if (!TurnstileService::verifyFor('admin_login', $turnstileToken !== '' ? $turnstileToken : null, clientIp())) {
$this->error('人机验证失败,请完成验证后重试');
}
}
$db = Database::getInstance();
@@ -133,10 +140,10 @@ class AuthController extends Controller
$this->error('两次输入的密码不一致');
}
// Cloudflare Turnstile(按系统配置开关与入口白名单)
$turnstileToken = trim((string) ($input['turnstile_token'] ?? ''));
if (!TurnstileService::verifyFor('agent_register', $turnstileToken !== '' ? $turnstileToken : null, clientIp())) {
$this->error('人机验证失败,请完成验证后重试');
// 图形数字验证码(代理注册)
$captchaCode = trim((string) ($input['captcha_code'] ?? ''));
if (!CaptchaService::verify($captchaCode)) {
$this->error('图形验证码错误或已过期,请刷新后重试');
}
// 手机号格式验证
@@ -832,6 +832,22 @@ class PublicController extends Controller
], 'ok');
}
/**
* 图形数字验证码(SVG,代理登录/注册用)
* GET /api/public/captcha
*/
public function captcha(): void
{
[, $svg] = \App\Services\CaptchaService::generate();
header('Content-Type: image/svg+xml; charset=UTF-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Pragma: no-cache');
header('Expires: 0');
echo $svg;
exit;
}
/**
* 获取公告列表(公开/客户端)
* GET /api/public/announcements?target=client&project_id=1&limit=10