1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-25 04:07:17 +08:00
2020-03-16 15:33:36 +08:00

31 lines
703 B
PHP

<?php
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Util\Verification as VerifyUtil;
use App\Services\Captcha as CaptchaService;
class Security extends Validator
{
public function checkVerifyCode($key, $code)
{
if (!VerifyUtil::checkCode($key, $code)) {
throw new BadRequestException('security.invalid_verify_code');
}
}
public function checkCaptchaCode($ticket, $rand)
{
$captchaService = new CaptchaService();
$result = $captchaService->verify($ticket, $rand);
if (!$result) {
throw new BadRequestException('security.invalid_captcha_code');
}
}
}