pull/7309/head
Your Name 1 week ago
parent 55dab635a8
commit 648a901aae

@ -0,0 +1,65 @@
<?php
namespace App\Console\Commands\Admin;
use App\Services\ConfigCacheService;
use Illuminate\Console\Command;
use function Laravel\Prompts\info;
use function Laravel\Prompts\warning;
/**
* Enables captcha and turns on the per-surface toggles.
*
* Because captcha settings are stored in the config-cache DB table (which
* overrides env/config-file values), enabling captcha via .env alone has no
* effect on an instance that already has rows. This command writes the correct
* rows so the change takes effect immediately.
*/
final class CaptchaEnableCommand extends Command
{
protected $signature = 'captcha:enable
{--surfaces=* : Limit to specific surfaces (login, register, forgot_password, password_reset, forgot_email, curated_register). Defaults to all.}
{--all-surfaces : Enable every surface (default when no --surfaces given)}';
protected $description = 'Enable captcha and its per-surface toggles in the config cache';
private const SURFACES = [
'login',
'register',
'forgot_password',
'password_reset',
'forgot_email',
'curated_register',
];
public function handle(): int
{
$driver = config_cache('captcha.driver') ?: config('captcha.driver', 'hcaptcha');
if (! app('captcha.manager')->driver($driver)->isConfigured()) {
warning("The active captcha driver [{$driver}] is not fully configured.");
warning('Set its credentials in the admin panel or .env before enabling, or the widget will not verify.');
}
ConfigCacheService::put('captcha.enabled', true);
info('captcha.enabled => true');
$requested = (array) $this->option('surfaces');
$surfaces = empty($requested) ? self::SURFACES : $requested;
foreach ($surfaces as $surface) {
if (! in_array($surface, self::SURFACES, true)) {
warning("Skipping unknown surface: {$surface}");
continue;
}
ConfigCacheService::put('captcha.active.'.$surface, true);
info("captcha.active.{$surface} => true");
}
info('Done. Active driver: '.$driver);
return self::SUCCESS;
}
}

File diff suppressed because one or more lines are too long

@ -16,7 +16,7 @@
"/js/profile-directory.js": "/js/profile-directory.js?id=316f0746cc50f5e5bbb790f11494c6ec",
"/js/story-compose.js": "/js/story-compose.js?id=53bba3b9d435cbd7a1689fc07f15439c",
"/js/direct.js": "/js/direct.js?id=7d716b0453d4ad885cb600c0cef953aa",
"/js/admin.js": "/js/admin.js?id=02975d69f702e4a4372c814b4609cf2b",
"/js/admin.js": "/js/admin.js?id=5a15e38ce02a4d4b8b112ef9f7b8202c",
"/js/spa.js": "/js/spa.js?id=453c913067fd89db4897f6159c163105",
"/js/stories.js": "/js/stories.js?id=8565c19bc915466ed5dd98076cfa3f04",
"/js/portfolio.js": "/js/portfolio.js?id=2dfd35982335ad4eca174b70bc0e9bb4",

@ -495,7 +495,7 @@
</div>
<hr class="mt-2 mb-4">
<div class="row">
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-6 mb-3">
<div class="custom-control custom-checkbox">
<input
type="checkbox"
@ -506,7 +506,7 @@
<label class="custom-control-label font-weight-bold" for="captcha_on_login">Login Captcha</label>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-6 mb-3">
<div class="custom-control custom-checkbox">
<input
type="checkbox"
@ -517,7 +517,7 @@
<label class="custom-control-label font-weight-bold" for="captcha_on_register">Register Captcha</label>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-6 mb-3">
<div class="custom-control custom-checkbox">
<input
type="checkbox"
@ -528,7 +528,7 @@
<label class="custom-control-label font-weight-bold" for="captcha_on_forgot_password">Forgot Password Captcha</label>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-6 mb-3">
<div class="custom-control custom-checkbox">
<input
type="checkbox"
@ -539,7 +539,7 @@
<label class="custom-control-label font-weight-bold" for="captcha_on_password_reset">Password Reset Captcha</label>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-6 mb-3">
<div class="custom-control custom-checkbox">
<input
type="checkbox"
@ -550,7 +550,7 @@
<label class="custom-control-label font-weight-bold" for="captcha_on_curated_register">Curated Register Captcha</label>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="col-12 col-lg-6 mb-3">
<div class="custom-control custom-checkbox">
<input
type="checkbox"

Loading…
Cancel
Save