User tests: Successful: Unsuccessful:
Now you can't have multiple recaptcha's on a single page. Also 3rt party support doesn't work correct.
1) Install Kunena, enable recaptcha on joomla and kunena, also setup category correct, and enable public write option on kunena config.
also set option captcha for guests and users
2) Create a new topic on kunena, or reply topic.
3) You will not see any recaptcha
You see recaptcha on new topic, also you can now have multiple recapcha's. like one a topic with multiple replies.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
when we do this: https://github.com/Kunena/Kunena-Forum/blob/develop/components/com_kunena/site/controller/topic/form/create/display.php#L81
Its not working anymore on J3.5, on J3.4 its working correct.
What i see on the code, its just loading the js, nothing else.
hm, strange ... and even at least one reCAPTCHA did not displayed?
What i see on the code, its just loading the js, nothing else.
it actually do "Automatically render the reCAPTCHA widget" https://developers.google.com/recaptcha/docs/display
@Fedik we don't use ondispaly
we use this: https://github.com/Kunena/Kunena-Forum/blob/develop/components/com_kunena/site/template/crypsis/layouts/message/edit/quickreply.php#L122
only the jquery isn't added to the html:
jQuery(document).ready(function($) {$(window).load(function() {grecaptcha.render("dynamic_recaptcha_1", {sitekey: "6LeoGscSAAAAAE8OqeBj4_foU-pfRNK4xmjMxyiu", theme: "clean"});});});
we don't use
ondispaly
that the reason of:
Its not working anymore on J3.5, on J3.4 its working correct.
No one can guarantee that all will work if you use Joomla Captcha API incorrect
you just need to render result of onDispaly
there https://github.com/Kunena/Kunena-Forum/blob/develop/components/com_kunena/site/template/crypsis/layouts/message/edit/quickreply.php#L122
From what i understand under J3.5, you have choosed the easiest method which is able to load only one captcha in the page and not multiple captcha.
hm, yes you are right, multiple reCaptcha does not work,
but suggested changes is too "old school"
I have other idea, but need wait for weekend ....
@Fedik, google recaptcha API seems to not support loading multiple recaptcha with render=onload method. The explicit method (render=explicit) with a onload callback (onload=xxxxxxx) is need for that.
So, just as a PoC, how about replacing this line (https://github.com/joomla/joomla-cms/blob/staging/plugins/captcha/recaptcha/recaptcha.php#L60) for something like this:
JHtml::_('script', 'system/captcha.js', false, true);
$file = 'https://www.google.com/recaptcha/api.js?onload=onLoadCaptcha&render=explicit&hl=' . JFactory::getLanguage()->getTag();
And then create a js file "captcha.js" in "/media/system/js/" with this content:
// IE 8 compatibility
if (typeof Array.prototype.forEach != "function") {
Array.prototype.forEach = function(callback){
for (var i = 0; i < this.length; i++){
callback.apply(this, [this[i], i, this]);
}
};
}
// Onload captcha event
window.onLoadCaptcha = function()
{
Array.prototype.forEach.call(document.getElementsByClassName("g-recaptcha"), function(element, index, array)
{
grecaptcha.render(element.getAttribute("id"),
{
"sitekey": element.getAttribute("data-sitekey"),
"theme": element.getAttribute("data-theme"),
"size": element.getAttribute("data-size")
});
});
}
@810, would something like this work?
@andrepereiradasilva yes, something like this will work, but there still a way to optimize it
Sure :). Will wait for your PR and will test it.
why do we care about IE8?
Bear
On 2/12/2016 07:05, andrepereiradasilva wrote:
@Fedik https://github.com/Fedik, google recaptcha API seems to not
support loading multiple recaptcha with render=onload method. The
explicit method (render=explicit) with a onload callback
(onload=xxxxxxx) is need for that.So, just as a PoC, how about replacing this line
(https://github.com/joomla/joomla-cms/blob/staging/plugins/captcha/recaptcha/recaptcha.php#L60)
for something like this:JHtml::_('script', 'system/captcha.js', false, true);
$file =
'https://www.google.com/recaptcha/api.js?onload=onLoadCaptcha&render=explicit&hl='
. JFactory::getLanguage()->getTag();And then create a js file "captcha.js" in "/media/system/js/" with
this content:// IE 8 compatibility
if (typeof Array.prototype.forEach != "function") {
Array.prototype.forEach = function(callback){
for (var i= 0; i< this.length; i++){
callback.apply(this, [this[i], i,this]);
}
};
}// Onload captcha event
window.onLoadCaptcha = function()
{
Array.prototype.forEach.call(document.getElementsByClassName("g-recaptcha"),function(element,index,array)
{
grecaptcha.render(element.getAttribute("id"),
{
"sitekey": element.getAttribute("data-sitekey"),
"theme": element.getAttribute("data-theme"),
"size": element.getAttribute("data-size")
});
});
}@810 https://github.com/810, would something like this work?
—
Reply to this email directly or view it on GitHub
#8867 (comment).
Ok, i tested this:
JHtml::_('script', 'captcha.js', false, true);
$file = 'https://www.google.com/recaptcha/api.js?onload=onLoadCaptcha&render=explicit&hl=' . JFactory::getLanguage()->getTag();
and:
// IE 8 compatibility
if (typeof Array.prototype.forEach != "function") {
Array.prototype.forEach = function(callback){
for (var i = 0; i < this.length; i++){
callback.apply(this, [this[i], i, this]);
}
};
}
// Onload captcha event
window.onLoadCaptcha = function()
{
Array.prototype.forEach.call(document.getElementsByClassName("g-recaptcha"), function(element, index, array)
{
grecaptcha.render(element.getAttribute("id"),
{
"sitekey": element.getAttribute("data-sitekey"),
"theme": element.getAttribute("data-theme"),
"size": element.getAttribute("data-size")
});
});
};
But i get: Verification expired. Check the checkbox again.
ok. let's wait for Fedik PR
i think this PR can be closed now.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-02-16 18:17:45 |
Closed_By | ⇒ | brianteeman |
Works with his fix.