支持关闭验证码

更新配置示例
This commit is contained in:
Chenx221 2024-02-28 16:07:39 +08:00
parent 5153d3889d
commit 0d7bf4b6af
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@ DB_HOST=localhost:3306 # 数据库地址
DB_NAME=yii2basic # 数据库名
DB_USERNAME=root # 数据库用户名
DB_PASSWORD= # 数据库密码
VERIFY_PROVIDER= # 验证服务提供商[reCAPTCHA,hCaptcha,Turnstile]
VERIFY_PROVIDER= # 验证服务提供商[reCAPTCHA,hCaptcha,Turnstile,None]
RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI # Google Recaptcha Site Key # Test Site Key
RECAPTCHA_SECRET=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe # Google Recaptcha Secret # Test Key
HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001 # hCaptcha Site Key # Test Site Key

View File

@ -168,7 +168,7 @@ class UserController extends Controller
$isCaptchaValid = $this->validateTurnstile($captchaResponse);
}
if ($captchaResponse !== null && $isCaptchaValid) {
if (($captchaResponse !== null && $isCaptchaValid) || ($verifyProvider === 'None')) {
if ($model->login()) {
return $this->goBack();
} else {
@ -287,7 +287,7 @@ class UserController extends Controller
$isCaptchaValid = $this->validateTurnstile($captchaResponse);
}
if ($captchaResponse !== null && $isCaptchaValid) {
if (($captchaResponse !== null && $isCaptchaValid) || ($verifyProvider === 'None')) {
$raw_password = $model->password;
$model->password = Yii::$app->security->generatePasswordHash($raw_password);
$model->auth_key = Yii::$app->security->generateRandomString();