reCaptcha on Signup/Login Page
Moderators: Developer, Contributor
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
reCaptcha on Signup/Login Page
I'm trying to implement a reCaptcha v2 Checkbox on my Signup/Login page. I have tried both methods on this page: https://developers.google.com/recaptcha/docs/display but the field doesn't show. See the attached image. I'm wondering if I'm doing something wrong. I have implemented this on other PHP software through plugins but I can't figure out why it won't show.
Re: reCaptcha on Signup/Login Page
There is a standard setting within Mantis:
/**
* use captcha image to validate subscription it requires GD library installed
* @global integer $g_signup_use_captcha
*/
$g_signup_use_captcha = ON;
So it is available, no need to change code for that.
/**
* use captcha image to validate subscription it requires GD library installed
* @global integer $g_signup_use_captcha
*/
$g_signup_use_captcha = ON;
So it is available, no need to change code for that.
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
I don't care for the built-in one as I've had people complain that they have entered the captcha correctly and it still gives an error so I would rather use reCaptcha and why MantisBT doesn't use reCaptcha instead of a custom built one beats me.
Re: reCaptcha on Signup/Login Page
In principle you should do this via a plugin but otherwise i would follow this:
http://acmeextension.com/integrate-goog ... -with-php/
http://acmeextension.com/integrate-goog ... -with-php/
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
I always do things this way, edit files to see what needs to be replaced via plugin then put it all back to normal and start building the files to replace code in the files via a plugin. Thanks for the link, I'll check it out and report back.cas wrote: ↑27 Aug 2020, 11:21 In principle you should do this via a plugin but otherwise i would follow this:
http://acmeextension.com/integrate-goog ... -with-php/
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
I checked it out, reset the pages back to the original format, and tried just adding reCaptcha v2 Checkbox with MantisBT Captcha set to OFF and I put the field outside the if condition. Still not showing and I don't understand why it's not showing.
Re: reCaptcha on Signup/Login Page
Do you already have a valid key?
Re: reCaptcha on Signup/Login Page
It has some something to do with "noscript" tags used by recaptcha
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
I tried another method which used those tags but also with the other solutions I face the same issue as you.
Check out what they write here:
https://stackoverflow.com/questions/308 ... ot-showing
Check out what they write here:
https://stackoverflow.com/questions/308 ... ot-showing
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
Thanks looking into it. About to start a new thread about using my plugin to replace code in a specific page.cas wrote: ↑27 Aug 2020, 15:00 I tried another method which used those tags but also with the other solutions I face the same issue as you.
Check out what they write here:
https://stackoverflow.com/questions/308 ... ot-showing
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
I did some tests on a completely new page I created called testload.php where I added everything and a test form. It all displays and shows correctly, I even added a script call before </head> making the google api call second to last and it still worked. So I'm wondering if there is something on the signup_page.php that is causing it to not load. Any suggestions?
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
Update: I tried implementing hCaptcha and still have the same issue with the box not showing at all and I can't figure out what could be interfering to make it not show.
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
UPDATE AGAIN: I think I found my problem and that is with content security policy so can someone let me know if I'm doing this right.
I'm not even sure that is working because the captcha box still isn't showing. The space for it is now there like the box is showing but there is nothing sooo appreciate all the help.
Code: Select all
function hooks(){
return array(
"EVENT_CORE_HEADERS" => 'csp_headers',
"EVENT_LAYOUT_RESOURCES" => 'scripts'
);
}
function csp_headers() {
http_csp_add( 'script-src', "https://hcaptcha.com" );
http_csp_add( 'script-src', "https://*.hcaptcha.com");
http_csp_add( 'image-src', "https://hcaptcha.com");
http_csp_add( 'image-src', "https://*.hcaptcha.com");
http_csp_add( 'style-src', "https://hcaptcha.com");
http_csp_add( 'style-src', "https://*.hcaptcha.com");
}
-
- Posts: 21
- Joined: 24 Aug 2020, 21:47
- Contact:
Re: reCaptcha on Signup/Login Page
Final update: After hours of digging and testing, this thread https://www.mantisbt.org/bugs/view.php?id=14679 had the answer. It was CSP blocking it from loading. Once I added the sites to CSP, it loaded and works. Now to figure out where it calls to insert the user so it can check for captcha before inserting the user into the database.