albertcht / invisible-recaptcha

An invisible reCAPTCHA package for Laravel, Lumen, CI or native PHP.
MIT License
603 stars 163 forks source link

Full support for Multi form recaptcha #158

Open timbogdanov opened 2 years ago

timbogdanov commented 2 years ago

Could we add full support for multiple form Recaptcha on this?

In the docs, I've read it saying that most of the time if you need Recaptcha more than once on a single page, you're doing it wrong. That can't be further from the truth.

Explain then how you go around with a login page, that accepts email and password and is validated by Recaptcha, and at the same time, has a button on the side of that same page. And that button opens a feedback form, also validated by Recaptcha.

Right now, I do see some dev support for multiple Recaptcha on the page, but it looks like it can only be done through jquery.

Any advice would be appreciated.

rezanadimi72 commented 1 year ago

Hi @timbogdanov you can use this scenario:

in App\Providers\AppServiceProvider register() method add this: ` putenv("INVISIBLE_RECAPTCHA_SITEKEY=AAAAA" );

    putenv("INVISIBLE_RECAPTCHA_SECRETKEY=BBBB" );
   `

AAAAA and BBBB set in your request

example:

in restful Api for Android and WebApplication most define two Google Recaptcha

in .env file:

` INVISIBLE_RECAPTCHA_SITEKEY_WEB=AAA

INVISIBLE_RECAPTCHA_SECRETKEY_WEB=BBB

INVISIBLE_RECAPTCHA_SITEKEY_ANDROID=CCC

INVISIBLE_RECAPTCHA_SECRETKEY_ANDROID=DDD `

and in register() method get request agent and set env dynamically