feature: google recaptcha

This commit is contained in:
Tokumeikoi
2020-10-09 23:27:36 +08:00
parent 3d26fda064
commit 54ab44c3fd
7 changed files with 30 additions and 4 deletions

View File

@ -14,11 +14,19 @@ use App\Models\InviteCode;
use App\Utils\Helper;
use App\Utils\Dict;
use App\Utils\CacheKey;
use ReCaptcha\ReCaptcha;
class AuthController extends Controller
{
public function register(AuthRegister $request)
{
if ((int)config('v2board.recaptcha_enable', 0)) {
$recaptcha = new ReCaptcha(config('v2board.recaptcha_key'));
$recaptchaResp = $recaptcha->verify($request->input('recaptcha_data'));
if (!$recaptchaResp->isSuccess()) {
abort(500, '验证码有误');
}
}
if ((int)config('v2board.email_whitelist_enable', 0)) {
if (!Helper::emailSuffixVerify(
$request->input('email'),