Skip to content
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

Recaptcha doesn't work #470

Open
D-Simona-G opened this issue Dec 12, 2023 · 8 comments · May be fixed by #475
Open

Recaptcha doesn't work #470

D-Simona-G opened this issue Dec 12, 2023 · 8 comments · May be fixed by #475

Comments

@D-Simona-G
Copy link

D-Simona-G commented Dec 12, 2023

Recaptcha doesn't work with the custom Keycloakify theme I made, despite the property "recaptchaRequired" being true & "recaptchaSiteKey" having the appropriate value (using Google Recaptcha). The html element itself appears in the DOM, but for some reason it's not "populated" as expected.

Screenshot 2023-12-12 001121

If for the same client, I swap the Keycloakify theme to a keycloak built-in one, it works completely fine. I have used the starter project (latest Keycloakify version) to build a Keycloak standalone theme, not an app, thus not sure if that has anything to do with it, although it shouldn't pose any problem.

I'd really appreciate any pointer/idea on how to solve this/why this might be happening. TIA.

@garronej
Copy link
Collaborator

Hello @D-Simona-G,

If you try with the theme of the starter does it work?

@D-Simona-G
Copy link
Author

D-Simona-G commented Dec 12, 2023

thanks for your prompt reply!

I did try both with your suggestion and with a freshly built one from the keycloakify-starter repo (without any of my modifications). And it doesn't work, it's the same situation that I showed in my above screenshot.

Forgot to mention my Keycloak server version is 23.0.1

@garronej
Copy link
Collaborator

Well then I guess it means that there's a bug in this page.

I didn't implement it myself.

I encourage you to copy over the page to your project and try fixing it, it's usually quite simple since the base Keycloak page are very basic.

If you find the bug you are very wellcome to submit a pull request or report your solution here.

@D-Simona-G
Copy link
Author

Working on it. If I do manage to fix it I will submit a PR, cheers!

@D-Simona-G
Copy link
Author

D-Simona-G commented Dec 14, 2023

@garronej Sorry for late reply, been quite busy, but I found and fixed the bug on my end. The problem stems from client-side navigation and component lifecycle which was interfering with the correct loading/rendering of the reCaptcha script/widget. E.g., navigating from the the Login page to Register page would result in the widget not rendering, but whilst on Register page, if you'd "hard" refresh the browser or clear cache, it would eventually render. On subsequent refreshes though, it would again not render. This doesn't happen with built-in Keycloak themes for obvious reasons.

Initially, I installed a small package called Reaptcha, to test my theory and that solved all the issues. But figured that some people might not even use reCaptcha feature so adding one more dependency wasn't necessarily justified + it was a bit too much for what was needed imo.
So I ended up using an useEffect hook in the RegisterUserProfile.tsx that manages the reCaptcha script.

If this sounds ok to you, I am happy to create a PR. If so, on which repo should it be?

@garronej
Copy link
Collaborator

Hey @D-Simona-G,

Thank you for the thorough explanation. Yes, please create the pull request. While I can't guarantee that I'll merge it as-is, I might need to make some adjustments. In any case, it will be a very valuable reference for people encountering the same issue as you.

@D-Simona-G D-Simona-G linked a pull request Dec 18, 2023 that will close this issue
@AlexisZankowitch
Copy link

I also had a similar issue on the Register page. Using the fix proposed in the PR solved it. Thank you @D-Simona-G

@garronej
Copy link
Collaborator

garronej commented May 7, 2024

Thanks for reporting @AlexisZankowitch,
The next release will have this fixed

Ref: #538

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants