1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00
2020-01-30 16:51:10 +08:00

31 lines
715 B
PHP

<?php
namespace App\Validators;
use App\Exceptions\BadRequest as BadRequestException;
use App\Library\Util\Verification as VerificationUtil;
use App\Services\Captcha as CaptchaService;
class Security extends Validator
{
public function checkVerifyCode($key, $code)
{
if (!VerificationUtil::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');
}
}
}