-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple captcha elements on page fails #9138
Comments
It is your assumption or you can prove it? 😃 On real it works fine, as there can be submitted only the one form with captcha. |
@Fedik -- how can I prove it? I posted the steps to duplicate the issue-- I could post a screenshot of the source of the page with the form showing the duplicate tokens and captcha elements, or a video showing how the second captcha fails, but this wouldn't prove anything more than me saying it. Thanks |
A change( #9111) has just been committed to the current staging and will be in 3.5beta3 hopefully released today that I hope resolves this. Please test and confirm and then this can be closed This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9138. |
@brianteeman -- thanks. To be clear, does this PR require the use of a hardcoded div with the g-recaptcha class? It doesn't appear to work using the normal captcha field element as shown in my example. |
please see https://developers.google.com/recaptcha/docs/display |
@Fedik -- thanks, but isn't the point of standardized Joomla fields that as a component developer we can just use the generic captcha field type and expect that it will work regardless of which captcha plugin a user has enabled? I know how to implement a recaptcha element in plain HTML-- I'm interested in using the Joomla captcha element in an XML form definition. Can you provide an example of using multiple captcha form fields in the XML form? |
No. Just as a test if you use the latest staging and add: <field
name="captcha2"
type="captcha"
label="COM_USERS_CAPTCHA_LABEL"
description="COM_USERS_CAPTCHA_DESC"
validate="captcha"
/> after https://github.com/joomla/joomla-cms/blob/staging/components/com_users/models/forms/remind.xml#L21 line. Them go to |
I've tested this on the Joomla 3.5-rc branch, and the ID of the div is identical for both captcha elements:
So the first captcha validates correctly, the second one does not-- it throws an error saying it's unable to contact Google. I suspect that if you inspect the source on your dual captcha test, you'll see that both captchas are identical, rather than having one element with the div ID of |
I still cannot recreate your issue. You got duplicated ID because you have 2 form where the same name of the capcha field, it also true for any other field with the same name. You can try to correct the form |
@Fedik -- thanks, I have verified that your fix works when the two captchas are in the same When the page loads, apparently when the second captcha is rendered, it falls back after the initial check for a captcha and loads the already loaded one instead of rendering the new one. I hope this is clear. |
I have tried 2 capcha fields in 2 separated forms at the one page, and all works fine for me. I still suggest you to review your code that responsible for load/handle that forms. I have a doubt that it is Joomla issue. |
Thanks for your patience @Fedik -- this was actually an unrelated piece of code that had been corrupting the captcha output. Your fix works, and I appreciate your help! |
If you create multiple forms on a page (eg. tabbed forms that submit separately) and use the Joomla captcha form element, the first captcha is simply duplicated which makes the second instance of the captcha fail to work.
example:
I believe
JCaptcha::getInstance()
should be using the namespace of the field to generate unique signatures for the different captcha instances since the namespace is passed in the $options array:However, if you dump the signature in both forms, you'll see they are identical, and the Google token is identical for both captcha instances as well, meaning the second instance can never work.
The text was updated successfully, but these errors were encountered: