Skip to content

Commit

Permalink
优化Geetest验证并新增Google reCAPTCHA
Browse files Browse the repository at this point in the history
  • Loading branch information
MIse committed Mar 20, 2019
1 parent da38cd7 commit fdb95f6
Show file tree
Hide file tree
Showing 15 changed files with 491 additions and 181 deletions.
14 changes: 13 additions & 1 deletion app/Components/CaptchaVerify.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
/**
* 从后台获取 Geetest_id 和 Geetest_key
*/
public static function geetestGetKey()
public static function geetestCaptchaGetConfig()
{
return [
"geetest_id" => Helpers::systemConfig()["geetest_id"],
"geetest_key" => Helpers::systemConfig()["geetest_key"]
];
}

/**
* 从后台获取 google_captcha_sitekey 和 google_captcha_secret
*/
public static function googleCaptchaGetConfig()
{
return [
"sitekey" => Helpers::systemConfig()["google_captcha_sitekey"],
"secret" => Helpers::systemConfig()["google_captcha_secret"],
"options" => []
];
}
}

?>
13 changes: 10 additions & 3 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,24 @@ public function login(Request $request)
$result = $this->validate($request, [
'geetest_challenge' => 'required|geetest'
], [
'geetest' => config('geetest.server_fail_alert')
'geetest' => trans('login.fail_captcha')
]);

if (!$result) {
Session::flash('errorMsg', config('geetest.server_fail_alert'));
Session::flash('errorMsg', trans('login.fail_captcha'));
return Redirect::back()->withInput();
}
break;
case 3:
// Google reCAPTCHA
echo 'Google reCAPTCHA';
$result = $this->validate($request,[
'g-recaptcha-response' => 'required|captcha'
]);

if (!$result) {
Session::flash('errorMsg', trans('login.fail_captcha'));
return Redirect::back()->withInput();
}
break;
default:
# nothing..
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"mews/captcha": "^2.2",
"mews/purifier": "^2.1",
"misechow/geetest": "^1.0",
"misechow/no-captcha": "^1.0",
"openlss/lib-array2xml": "^0.5.1",
"overtrue/laravel-lang": "^3.0",
"phpoffice/phpspreadsheet": "^1.6",
Expand Down
Loading

0 comments on commit fdb95f6

Please sign in to comment.