Comments (15)
I just wake up. I am looking into it soon
from laravel-google-recaptcha-v3.
Hi @HdbKing
Looks like you have an issue with your Blade variable field
being empty.
This plugin requires a DOM element with a given ID in order to work.
I'm not sure why you need a variable ID, but I suggest you double check your controller is correctly setting up those needed vars.
from laravel-google-recaptcha-v3.
Hi @HdbKing
Looks like you have an issue with your Blade variable
field
being empty.This plugin requires a DOM element with a given ID in order to work.
I'm not sure why you need a variable ID, but I suggest you double check your controller is correctly setting up those needed vars.
If you use layout , render must in layout (
Include Template script in your bottom/header of your page, params should follow 'ID'=>'Action', e.g.
),
when you open other page, Some element will never exists in current page.
It is not a controller code problem.
from laravel-google-recaptcha-v3.
@HdbKing I have updated the package, the previous approach does not support background script (in your case, the render needs to always have a value to populate the action, otherwise it throws errors if the script cannot find the proper element id.)
I have added a new feature which allows the user to run the script on every page.
Please read the latest update and update your version to be >= ~2.2.6: https://github.com/RyanDaDeng/laravel-google-recaptcha-v3#blade-basic-usage
The render() function will only be applied to your form in the same file.
The background() function should be included at your home/layout page.
Also remember publish the config file again.
Note:
The root issue here is that Google reCAPTCHA api script only support onload() callback function to change display style and populate multiple actions on the same page, this requires Action to be defined as well as onload() function. If not use this feature, the script will be loaded slow and the custom style won't work.
However, if the user wants to run the script without action, the above approach won't work as it takes variables.
In order to resolve this issue, we might need to treat them separately. The function that I added (ReCaptchaV3::background()) which just simply loads google script and also check if any script has been loaded before, if the script has been loaded, the background() function will just return empty to avoid loading script multiple times in case of conflicting with Action approach.
Thank you for using the package.
Please let me know if you have any confusions or suggestions. I am willing to make the changes.
from laravel-google-recaptcha-v3.
@HdbKing I have updated the package, the previous approach does not support background script (in your case, the render needs to always have a value to populate the action, otherwise it throws errors if the script cannot find the proper element id.)
I have added a new feature which allows the user to run the script on every page.
Please read the latest update and update your version to be >= ~2.2.6: https://github.com/RyanDaDeng/laravel-google-recaptcha-v3#blade-basic-usage
The render() function will only be applied to your form in the same file.
The background() function should be included at your bottom of your home/layout page.
Also remember publish the config file again.
Note:
The root issue here is that Google reCAPTCHA api script only support onload() callback function to change display style and populate multiple actions on the same page, this requires Action to be defined as well as onload() function. If not use this feature, the script will be loaded slow and the custom style won't work.However, if the user wants to run the script without action, the above approach won't work as it takes variables.
In order to resolve this issue, we might need to treat them separately. The function that I added (ReCaptchaV3::background()) which just simply loads google script and also check if any script has been loaded before, if the script has been loaded, the background() function will just return empty to avoid loading script multiple times in case of conflicting with Action approach.
Thank you for using the package.
Please let me know if you have any confusions or suggestions. I am willing to make the changes.
Still don't work. because onloadCallback still run firstly or same time, js don't like php , {{$field}} = null,
get same error
You still need
if (document.getElementById('{{$field}}')) {
let client{{$field}} = grecaptcha.render('{{$field}}'
let client{{$field}} = grecaptcha.render('{{$field}}', {
The problem is if grecaptcha.render(null)
script will stop
foreach will stop
And if you layout has render his form, script will stop in other page with render('said already rendered')
from laravel-google-recaptcha-v3.
@HdbKing Hmm, I am a bit confused. Can you provide me with your current Blade layout structure along with the script usage?
The render() function needs to be always binding to form. You should not put it explicitly. (Not head or bottom anymore after previous fix)
If you want it run globally, you then need to include background() function in your layout page.
You can only have one render() function in your form as well.
from laravel-google-recaptcha-v3.
@HdbKing Hmm, I am a bit confused. Can you provide me with your current Blade layout structure along with the script usage?
The render() function needs to be always binding to form. You should not put it explicitly. (Not head or bottom anymore after previous fix)
If you want it run globally, you then need to include background() function in your layout page.
You can only have one render() function in your form as well.
In fact it is same with auth:make structure .
wwww.abc.com/ added some form
wwww.abc.com/login added some form
layout.blade.php
some form
///header
{!! GoogleReCaptchaV3::render([
...
'navform_id'=>'navform',
'register_id'=>'register',
'changepass_id'=>'changepass',
...
]) !!}
{!! GoogleReCaptchaV3::background() !!}
index.blade.php
@extends('layouts.layout')
@section('index')
@endsection
from laravel-google-recaptcha-v3.
@HdbKing I see the problems there, however, I just come up with a perfect solution for it. Give me some minutes, I am running some tests
from laravel-google-recaptcha-v3.
@HdbKing Hello, please upgrade version again to be >= ~2.2.11 and publish the config file (sorry about that).
in your layout.blade.php, remove {!! GoogleReCaptchaV3::background() !!} and use {!! GoogleReCaptchaV3::init() !!}
Previous:
Initially, the package does not allow all form arrays in one single place in layout.blade.php, e.g. register form located at register.blade.php, you need to include it in only that file. (Sorry for my previous wrong instruction)
However ----,
New:
I have added if() check if the field exists as you suggested before, so you can either include everything in layout page or adding them separately in different page. (check updated documentation)
Basically, after upgrade, you just need to change background() to init() and placed it in very bottom of page, everything should work as expected.
Alternatively,
You can do this as well:
<form method="POST" action="/verify">
{!! GoogleReCaptchaV3::renderField('contact_us_id','contact_us_action') !!}
<input type="submit" value="submit">
</form>
from laravel-google-recaptcha-v3.
@HdbKing Also, it's better to check the updated README, let me know if this fix your issue (I believe so ^.^) I think the package is very complete now.
from laravel-google-recaptcha-v3.
@HdbKing Hello, please upgrade version again to be >= ~2.2.11 and publish the config file (sorry about that).
in your layout.blade.php, remove {!! GoogleReCaptchaV3::background() !!} and use {!! GoogleReCaptchaV3::init() !!}
Previous:
Initially, the package does not allow all form arrays in one single place in layout.blade.php, e.g. register form located at register.blade.php, you need to include it in only that file. (Sorry for my previous wrong instruction)
However ----,
New:
I have added if() check if the field exists as you suggested before, so you can either include everything in layout page or adding them separately in different page. (check updated documentation)Basically, after upgrade, you just need to change background() to init() and placed it in very bottom of page, everything should work as expected.
Alternatively,
You can do this as well:<form method="POST" action="/verify"> {!! GoogleReCaptchaV3::renderField('contact_us_id','contact_us_action') !!} <input type="submit" value="submit"> </form>
is new version
{!! GoogleReCaptchaV3::renderField('contact_us_id','contact_us_action') !!}
equal to
old version
+ {!! GoogleReCaptchaV3::renderField('contact_us_id','contact_us_action') !!} ???from laravel-google-recaptcha-v3.
@HdbKing That is alternative method, which is placed within the form. In your case, you just need to change background() to init(), everything should work.
from laravel-google-recaptcha-v3.
@HdbKing That is alternative method, which is placed within the form. In your case, you just need to change background() to init(), everything should work.
yes,it's worked.
Could you have more detail with "score_comparision"?
If "score" less than "threshold" , what will happen? I don't find any detail in readme
from laravel-google-recaptcha-v3.
It will return false and fails ReCAPTCHA
please play it a bit around.
from laravel-google-recaptcha-v3.
I will close this ticket, if you have any other problems please create a new ticket.
Happy coding.
from laravel-google-recaptcha-v3.
Related Issues (20)
- No way to translate message timeout-or-duplicate HOT 3
- Badge not rendering in the correct spot HOT 5
- Issue of generating renderField with @include HOT 1
- Laravel 8.0 release not installable HOT 3
- Deactivate CURLOPT_SSL_VERIFYPEER via config HOT 1
- Struggling to implement on registration HOT 3
- Returning "Successfully passed" as error
- Error: The action is timeout. HOT 3
- Error with vue component: gRecaptchaResponse: ["invalid-input-secret"] HOT 2
- Token is null HOT 3
- Unable to use properly with Vue HOT 2
- Missing-input-response HOT 1
- Uncaught SyntaxError: Unexpected end of input HOT 2
- TIMEOUT_OR_DUPLICATE HOT 1
- token times out after x time. HOT 1
- Usage with Livewire
- Badge still showing at the bottom of the page when background_badge_display set to false HOT 2
- It works for domain but not for its subdomains
- toDelete
- Issue with Validation class (Request) and function rules()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-google-recaptcha-v3.