Skip to content

Commit 8a89e3c

Browse files
committed
Update captcha, use config_cache helper
1 parent c96167f commit 8a89e3c

11 files changed

+22
-14
lines changed

app/Http/Controllers/Auth/ForgotPasswordController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function validateEmail(Request $request)
6262

6363
usleep(random_int(100000, 3000000));
6464

65-
if(config('captcha.enabled')) {
65+
if((bool) config_cache('captcha.enabled')) {
6666
$rules = [
6767
'email' => 'required|email',
6868
'h-captcha-response' => 'required|captcha'

app/Http/Controllers/Auth/LoginController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public function validateLogin($request)
7474
$messages = [];
7575

7676
if(
77-
config('captcha.enabled') ||
78-
config('captcha.active.login') ||
77+
(bool) config_cache('captcha.enabled') &&
78+
(bool) config_cache('captcha.active.login') ||
7979
(
80-
config('captcha.triggers.login.enabled') &&
80+
(bool) config_cache('captcha.triggers.login.enabled') &&
8181
request()->session()->has('login_attempts') &&
8282
request()->session()->get('login_attempts') >= config('captcha.triggers.login.attempts')
8383
)

app/Http/Controllers/Auth/RegisterController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function ($attribute, $value, $fail) {
137137
'password' => 'required|string|min:'.config('pixelfed.min_password_length').'|confirmed',
138138
];
139139

140-
if(config('captcha.enabled') || config('captcha.active.register')) {
140+
if((bool) config_cache('captcha.enabled') && (bool) config_cache('captcha.active.register')) {
141141
$rules['h-captcha-response'] = 'required|captcha';
142142
}
143143

app/Http/Controllers/Auth/ResetPasswordController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function rules()
5050
{
5151
usleep(random_int(100000, 3000000));
5252

53-
if(config('captcha.enabled')) {
53+
if((bool) config_cache('captcha.enabled')) {
5454
return [
5555
'token' => 'required',
5656
'email' => 'required|email',

app/Http/Controllers/UserEmailForgotController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function store(Request $request)
3434
'username.exists' => 'This username is no longer active or does not exist!'
3535
];
3636

37-
if(config('captcha.enabled') || config('captcha.active.login') || config('captcha.active.register')) {
37+
if((bool) config_cache('captcha.enabled')) {
3838
$rules['h-captcha-response'] = 'required|captcha';
3939
$messages['h-captcha-response.required'] = 'You need to complete the captcha!';
4040
}

app/Services/ConfigCacheService.php

+8
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ public static function get($key)
8989
'pixelfed.app_registration_confirm_rate_limit_decay',
9090
'instance.embed.profile',
9191
'instance.embed.post',
92+
93+
'captcha.enabled',
94+
'captcha.secret',
95+
'captcha.sitekey',
96+
'captcha.active.login',
97+
'captcha.active.register',
98+
'captcha.triggers.login.enabled',
99+
'captcha.triggers.login.attempts',
92100
// 'system.user_mode'
93101
];
94102

resources/views/auth/email/forgot.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class="form-control form-control-lg bg-glass text-white"
6565
</div>
6666
</div>
6767

68-
@if(config('captcha.enabled') || config('captcha.active.login') || config('captcha.active.register'))
68+
@if((bool) config_cache('captcha.enabled'))
6969
<label class="font-weight-bold small text-muted">Captcha</label>
7070
<div class="d-flex flex-grow-1">
7171
{!! Captcha::display(['data-theme' => 'dark']) !!}

resources/views/auth/login.blade.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
</div>
7777

7878
@if(
79-
config('captcha.enabled') ||
80-
config('captcha.active.login') ||
79+
(bool) config_cache('captcha.enabled') &&
80+
(bool) config_cache('captcha.active.login') ||
8181
(
82-
config('captcha.triggers.login.enabled') &&
82+
(bool) config_cache('captcha.triggers.login.enabled') &&
8383
request()->session()->has('login_attempts') &&
8484
request()->session()->get('login_attempts') >= config('captcha.triggers.login.attempts')
8585
)

resources/views/auth/passwords/email.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class="form-control form-control-lg bg-glass text-white"
5454
</div>
5555
</div>
5656

57-
@if(config('captcha.enabled'))
57+
@if((bool) config_cache('captcha.enabled'))
5858
<label class="font-weight-bold small text-muted">Captcha</label>
5959
<div class="d-flex flex-grow-1">
6060
{!! Captcha::display(['data-theme' => 'dark']) !!}

resources/views/auth/passwords/reset.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class="form-control form-control-lg bg-glass text-white{{ $errors->has('password
109109
</div>
110110
</div>
111111

112-
@if(config('captcha.enabled'))
112+
@if((bool) config_cache('captcha.enabled'))
113113
<label class="font-weight-bold small pt-3 text-muted">Captcha</label>
114114
<div class="d-flex flex-grow-1">
115115
{!! Captcha::display(['data-theme' => 'dark']) !!}

resources/views/settings/parental-controls/invite-register-form.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class="rounded-circle mr-2"
9191
</div>
9292
</div>
9393

94-
@if(config('captcha.enabled') || config('captcha.active.register'))
94+
@if((bool) config_cache('captcha.enabled'))
9595
<div class="d-flex justify-content-center my-3">
9696
{!! Captcha::display() !!}
9797
</div>

0 commit comments

Comments
 (0)