huacnlee / rucaptcha

Captcha Gem for Rails, which generates captcha image by Rust.
https://huacnlee.github.io/rucaptcha
MIT License
695 stars 133 forks source link

fix: sometimes rucaptcha input fails if rucaptcha_image_tag used multiple times in the same request #96

Closed srghma closed 3 years ago

srghma commented 3 years ago

My previous commit https://github.com/huacnlee/rucaptcha/commit/5c01371daac13d8451272bb2e37e1bdaaceee472 did more harm than use

Before commit 5c01371daac13d8451272bb2e37e1bdaaceee472: if rucaptcha_image_tag function is used in place1, place2, place3 it would generate the same src ru_captcha.root_path and browser would request image only once AND application would set expected code to cache store only once too

After 5c01371daac13d8451272bb2e37e1bdaaceee472: if rucaptcha_image_tag function is used in place1, place2, place3 it would generate the 3 different src #{ru_captcha.root_path}?t=1111, #{ru_captcha.root_path}?t=2222, #{ru_captcha.root_path}?t=3333 and browser would request image 3 times application would set expected code to cache store 3 times too AND the last code wins

Now: if rucaptcha_image_tag function is used in place1, place2, place3 it would generate the same src #{ru_captcha.root_path}?t=1111 and browser would request image once application would set expected code to cache store once too