thinhbuzz / laravel-google-captcha Goto Github PK
View Code? Open in Web Editor NEWGoogle captcha for Laravel 5, Laravel 6, Laravel 7, Laravel 8, Laravel 9 and Laravel 10, support multiple captcha on page
License: MIT License
Google captcha for Laravel 5, Laravel 6, Laravel 7, Laravel 8, Laravel 9 and Laravel 10, support multiple captcha on page
License: MIT License
Remove call to Form
facade
{!! Form::captcha($attributes) !!}
because Form removed from Laravel 5
Read the testing instructions which work well if you are testing forms but what about testing using a simple post request? Thanks in advance for the help!
Eg:
$this->post('/register', [
'username' => 'TestUser',
'email' => '[email protected]',
'password' => 'Password123',
'password_confirmation' => 'Password123',
'terms' => '1',
]);
$this->assertDatabaseHas('users', [
'email' => '[email protected]',
'username' => 'TestUser',
]);
Would be nice to support testing inside the package. Something like https://github.com/anhskohbo/no-captcha testing facade would be cool.
Please update to be available for Laravel 5.2.*. Thank you.
Hello,
I would like to add multiple captcha on multiple form but on the same page.
The problem is that the captcha JS file will be loaded X times as i include it one page instead of loading only one time.
I use this in my template : {!! Captcha::display([]) !!}
Someone already got this problem ?
Thanks
subj
Laravel: 5.6
PHP: 7.2
"name": "buzz/laravel-google-captcha",
"version": "v2.1.10",
file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0
[2019-01-23 10:05:41] production.ERROR: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 {"exception":"[object] (ErrorException(code: 0): file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 at /var/www/example.com/releases/6/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php:72)
hi i am using laravel 5.4. to google reCaptcha, i am facing an error
file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0
how to define 'request_method' ?
if i set 'request_method' => CurlPost or 'request_method' => "CurlPost' or 'request_method' => 'Curl' it showing Function CurlPost() does not exist.
thanks
Trying the invisible and I keep getting this error.
Hi there,
Let me start off by saying that I am very thankful for your recent update to this library to support multiple captchas on a single page!
I found however that I needed to update my integration tests as well with those new changes, and was wondering if this could be updated in the docs?
I have added three calls to my tests, could you tell me if this is the correct way to go? The first 2 shouldReceive
calls are already documented by you. This is for testing a page that is using multiple captchas.
// prevent validation error on captcha
CaptchaFacade::shouldReceive('verify')
->andReturn(true);
// provide hidden input for your 'required' validation
CaptchaFacade::shouldReceive('display')
->andReturn('<input type="hidden" name="g-recaptcha-response" value="1" />');
CaptchaFacade::shouldReceive("displayJs");
CaptchaFacade::shouldReceive("displayMultiple");
CaptchaFacade::shouldReceive("multiple");
Cheers
In case of an error during the second sending of data, the captcha does not work anymore. Although it is visually shown that you have passed it.
Screeanshot
I added the recaptcha on the page and getting this error.
any ideas?
How I can set $requestMethod in __construct \ReCaptcha\ReCaptcha https://github.com/thinhbuzz/laravel-google-captcha/blob/master/src/Captcha.php#L207
Fix from google set socket as request method google/recaptcha#36
js output
<script type="text/javascript">
var buzzNoCaptchaWidgetIds={};
var buzzNoCaptchaOnLoadCallback=function( {
buzzNoCaptchaWidgetIds["captcha_create_comment"]=grecaptcha.render('captcha_create_comment',
{"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE", "id":"captcha_create_comment"}
);
buzzNoCaptchaWidgetIds["captcha_create_consultation"]=grecaptcha.render('captcha_create_consultation',
{"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE","id":"captcha_create_consultation"}
);
buzzNoCaptchaWidgetIds["captcha_create_appointment"]=grecaptcha.render('captcha_create_appointment',
{"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE","id":"captcha_create_appointment"}
);
};</script>
I execute in the console
grecaptcha.reset(buzzNoCaptchaWidgetIds['captcha_create_consultation']);
As a result, the first captcha in the list of objects is reset (id captcha_create_comment)
Works as I understood on the same principle as before: the first counter is reset
{!! app('captcha')->display($attributes = [], $options = ['lang'=> 'vi'); !!}
Should be
{!! app('captcha')->display($attributes = [], $options = ['lang'=> 'vi']) !!}
At Usage\With custom language support
Please update composer.json to support Laravel 10.
Thanks!
Please give an example of how you reset the captcha if there are several of them on the page. I have not tried it all the same.
Are invisible reCAPTCHAs supported through this library?
I tried to use this library with the invisible data attribute (see v2 reCAPTCHA docs by Google):
{!! Captcha::display(['data-size' => 'invisible']) !!}
While this line hides the captcha, it also causes the validation to fail afterwards. Looking at Google documentation this flag should be the only change needed, but I can not figure out, why it does not work with this plugin. Any ideas? Or, maybe anybody here activly uses the invisible reCAPTCHAs already with this library?
Please Add Laravel 5.4 Support
Hi,
I used your plugin, it perfect but when i change language, it sometime still wrong.
i config my language by vi, in both file config/captcha.php and change option in display lang => vi but sometime it still english. Can you help me fix this ?
pls and thanks you
Hello,
any chance to support Laravel 9.0? Would be great!
Thanks!
Any plans on Laravel 5.5 support (especially the new package auto-discovery)?
Fatal error: Undefined constant 'Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider'
from the readme, chaging this
'Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider',
to this
Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider::class,
seems to fix the problem.
How to set the proxy for calling buzz/laravel-google-captcha
return [
'secret' => env('CAPTCHA_SECRET', 'default_secret'),
'sitekey' => env('CAPTCHA_SITEKEY', 'default_sitekey'),
/**
* @var string|null Default null
.
* Custom with function name (example customRequestCaptcha) or class@method (example \App\CustomRequestCaptcha@custom).
* Function must be return instance, read more in folder examples
*/
'request_method' => null,
'options' => [
'multiple' => false,
'lang' => app()->getLocale(),
],
'attributes' => [
'theme' => 'light'
],
];
please help asap
I get an error when adding Captcha::display()
to my view
Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>, as they will not be parsed
Because of <script>
tag that has been injected along with captcha div. I've already tried to set multiple
to true in config and adding Captcha::displayJs()
in the end of <body>
tag. It requires to create a <script>
tag with callback buzzNoCaptchaOnLoadCallback()
function inside that script and still not showing captcha (but eliminates the error message on loading)
Hello,
I followed all the steps in readme.md, but captcha validation is not running, could you help me or explain to me how validation works?
I'm new to laravel, so I still don't understand some parts of the framework
I think the problem is in Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider:boot()
method, you should not force using APP key if it is null.
I am running Dusk automation tests and none of this seem to work:
public function createApplication(): Application
{
...
$app['validator']->extend('captcha', function() {
fwrite(STDOUT, print_r("Bypassing captcha validation and returning explicit true!\n", TRUE));
return true;
});
CaptchaFacade::shouldReceive('verify')->andReturn(true);
CaptchaFacade::shouldReceive('display')
->andReturn('<input type="hidden" name="g-recaptcha-response" value="1" />');
return $app;
}
The error message is Failed to validate the captcha
. How to sort it?
here is the errors i got while trying to require it
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for buzz/laravel-google-captcha ^1.2 -> satisfiable by buzz/laravel-google-captcha[v1.2].
- Conclusion: remove laravel/framework v5.3.15
- Conclusion: don't install laravel/framework v5.3.15
- buzz/laravel-google-captcha v1.2 requires illuminate/support 5.0.|5.1.|5.2.* -> satisfiable by illuminate/support[v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7].
- don't install illuminate/support v5.2.19|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.21|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.24|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.25|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.26|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.27|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.28|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.31|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.32|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.37|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.43|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.45|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.0|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.22|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.25|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.26|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.28|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.33|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.0.4|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.1|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.13|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.16|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.2|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.20|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.22|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.25|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.28|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.30|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.31|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.41|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.6|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.1.8|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.0|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.6|don't install laravel/framework v5.3.15
- don't install illuminate/support v5.2.7|don't install laravel/framework v5.3.15
- Installation request for laravel/framework (locked at v5.3.15, required as 5.3.*) -> satisfiable by laravel/framework[v5.3.15].
Installation failed, reverting ./composer.json to its original content.
Please add Laravel 7 support.
I used of this rule to validate recaptcha:
$validate = Validator::make($request->all(), [
'g-recaptcha-response' => 'required|captcha',
'name' => 'required',
]);
But this way always return fail, even when i checked recaptcha
if ($validate->fails()) {
var_dump($vlidate);
dd('fails');
}
When i checked passes() method is true and when i don't check, passes() return false, but in both sitiuation fails() method is true
Is there is a way how can I specify a different access key for the captcha?
One captcha on one page, another captcha on another page.
So we can track usage of it separately.
how to make captcha responsive
So I started off running composer require buzz/laravel-google-captcha
install went fine.
Im running laravel 5.4
Add ServiceProvider to the providers array in app/config/app.php.
'Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider',
(seeing im 5.4 and this doesnt exist I did the following)
Add ServiceProvider to the providers array in config/app.php.
Buzz\LaravelGoogleCaptcha\CaptchaServiceProvider::class,
Then use Facade: add 'Captcha' => '\Buzz\LaravelGoogleCaptcha\CaptchaFacade', to the aliases array in app/config/app.php
(seeing im 5.4 and this doesnt exist I did the following)
Facade: add 'Captcha' => \Buzz\LaravelGoogleCaptcha\CaptchaFacade::class, to the aliases array in config/app.php
Then added my CAPTCHA_SECRET=[secret-key] CAPTCHA_SITEKEY=[site-key] with proper keys to my .env
Then placed {!! Captcha::display($attributes) !!} in my login.blade.php
When I goto login page I get the following error:
Undefined variable: attributes (View: /home/UNIT3D_2.0/resources/views/user/login.blade.php)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.