Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

pixelfed/pixelfed

6813 stars
4 code files
View pixelfed/pixelfed on GitHub

composer.json

Open in GitHub
{
//
"require": {
"php": "^7.3",
//
"buzz/laravel-h-captcha": "1.0.2"
},
//
}

config/captcha.php

Open in GitHub
return [
'enabled' => env('CAPTCHA_ENABLED', false),
'secret' => env('CAPTCHA_SECRET', 'default_secret'),
'sitekey' => env('CAPTCHA_SITEKEY', 'default_sitekey'),
'http_client' => \Buzz\LaravelHCaptcha\HttpClient::class,
'options' => [
'multiple' => false,
'lang' => app()->getLocale(),
],
'attributes' => [
'theme' => 'light'
],
];

app/Http/Controllers/Auth/LoginController.php

Open in GitHub
use App\Http\Controllers\Controller;
 
class LoginController extends Controller
{
//
public function validateLogin($request)
{
$rules = [
$this->username() => 'required|email',
'password' => 'required|string|min:6',
];
 
if(config('captcha.enabled')) {
$rules['h-captcha-response'] = 'required|captcha';
}
 
$this->validate($request, $rules);
}
//
}

resources/views/auth/login.blade.php

Open in GitHub
//
@if(config('captcha.enabled'))
<div class="d-flex justify-content-center mb-3">
{!! Captcha::display() !!}
</div>
@endif
//

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.