如何检查react-recaptcha-google是否已过期?

问题描述 投票:0回答:1

我根据此处的说明使用react-recaptcha-googlehttps://medium.com/codeep-io/how-to-use-google-recaptcha-with-react-38a5cd535e0d

    <ReCaptcha
        ref={(el) => {this.captchaDemo = el;}}
        size="normal"
        render="explicit"
        sitekey="my_key"
        onloadCallback={this.onLoadRecaptcha}
        verifyCallback={this.verifyCallback}
    />

  verifyCallback(recaptchaToken) {
    // This shows recaptchaToken  
    console.log(recaptchaToken, "<= your recaptcha token")
  }

验证码已过期,一段时间后会提示再次验证。

enter image description here

提交表格时,我需要检查令牌/验证码是否仍然有效-怎么做?如何验证提交的验证码是否过期?

如何在recaptchaToken功能之外再次获得verifyCallback

<button className="btn nvh-cta center-block" onClick={(e) => this.submitFeedback(e)}>SUBMIT</button>

submitFeedback(e) {
    console.log(this.captchaDemo); <- there is no token present in the captcha properties
}
reactjs recaptcha react-google-recaptcha
1个回答
0
投票
您可以在此处查看完整的代码:

Google reCAPTCHA in a ReactJS app

© www.soinside.com 2019 - 2024. All rights reserved.