First, install anhskohbo/no-captcha Package for Google reCaptcha code. Using this Package, we can generate reCaptcha code for our Application.
composer require anhskohbo/no-captcha
Type below command to Publish Config File
php artisan vendor:publish --provider="Anhskohbo\NoCaptcha\NoCaptchaServiceProvider"
In Env file add these lines
NOCAPTCHA_SECRET=6LfAxnYUAAAAAMFIDoHDyukSi4yHcYZp8q5WdB2m
NOCAPTCHA_SITEKEY=6LfAxnYUAAAAAH5JZ5xlK_iTjjkbdupMuvKeszYZ
Add this lines to your register or login page.
<div class="row">
<div class="col-md-4"></div>
<div class="form-group col-md-4">
<label for="ReCaptcha">Recaptcha:</label>
{!! NoCaptcha::renderJs() !!}
{!! NoCaptcha::display() !!}
</div>
</div>
Add in LoginContorller.php
protected function validateLogin(Request $request)
{
$this->validate($request,[
'email' => ['required', 'string', 'email'],
'password' => ['required', 'string'],
'g-recaptcha-response' => ['required','captcha'],
]);
}
Thank you for sharing this informative post on laravel. I am new to laravel and this post will really help me.
ReplyDeleteLaravel Web Development Services
Tecocraft Ltd has been empowering for creating custom Mobile App Development Company In UK. and solutions for customers willing to grow their business and want to provide a great user experience to end users.
ReplyDelete