VividCortex / angular-recaptcha

AngularJS directive to add a reCaptcha widget to your form
http://vividcortex.github.io/angular-recaptcha/
MIT License
496 stars 257 forks source link

Add documentation and example for on-expire attribute #67

Closed jpmckearin closed 9 years ago

iambrosi commented 9 years ago

Thanks @jpmckearin !

trickpattyFH20 commented 9 years ago

UPDATE I was having trouble figuring out what needed to be done to handle the expire event. Reading through the source of angular-recaptcha.js, I found the "reload" function vcRecaptchaService.reload() this was very helpful to me when I was setting up recaptcha, just thought I'd post it here since it's not in the docs


Do you guys have any tips on how you handle the "expire" event?

@jpmckearin @iambrosi

TheSharpieOne commented 9 years ago

@trickpattyFH20 There is no need to vcRecaptchaService.reload() when the timeout callback is called, it is just to notify the developer of the timeout so they can display messages or do whatever. Internally, the now invalid captcha response is cleared out of model and if the captcha is within a form control it will mark the form as invalid. Google internally resets the captcha.

trickpattyFH20 commented 9 years ago

@TheSharpieOne the functionality I was looking to achieve was the have a new empty re-captcha shown after a timeout on the re-captcha key on google's end. no sense in making a user refresh the page to get a new re-captcha when I can do it asynchronously in the timeout callback

TheSharpieOne commented 9 years ago

@trickpattyFH20 I see, you wanted a brand-new recaptcha instance rather than reusing the old one (by reuse, I mean "unchecking" the checkbox and allowing the user to "check" the same checkbox again). But really, vcRecaptchaService.reload() is not a "reload", it just calls recaptcha's reset(), which resets the same checkbox rather than creating a new instance.

Also, just fyi, without this module, or any additional code, the functionality you want happens automatically in recaptcha's code... give it a try.

Just don't want to make people think they have to use the callback to reset recaptcha, because they don't. Resetting the captcha happens automatically, asynchronously, and without the need to reload/refresh the page. The callback is just a convenience to let the developer be notified that the valid recaptcha has timed out.

trickpattyFH20 commented 9 years ago

ah ok, I didn't know the vanilla recaptcha code included that functionality, I just used this module for the convenience of it, thank you! @TheSharpieOne