如何在vuejs中集成AWS WAF验证码?

huangapple go评论64阅读模式
英文:

How to integrate AWS WAF Captcha in vuejs?

问题

我正在尝试将AWS验证码集成到我的登录界面中。

验证码已经显示,用户完成拼图并成功调用了验证API。

但是,我如何在拼图完成后获取成功状态?

AwsWafCaptcha.renderCaptcha(container, {
      apiKey: "ApiKeyHere",
      onSuccess: captchaExampleSuccessFunction,
      onError: captchaExampleErrorFunction
    });


captchaExampleSuccessFunction(wafToken) {
        window.AwsWafIntegration.fetch(this.captchaVerifiedFn());
    },

用户完成拼图后,我需要调用captchaVerifiedFn()。

任何帮助将不胜感激。

英文:

I'm trying to integrate aws captcha to my login screen.

the captcha renders, user completes puzzle and verify api is called successfully.

but how do I get the success status after puzzle completed

AwsWafCaptcha.renderCaptcha(container, {
      apiKey: "ApiKeyHere",
      onSuccess: captchaExampleSuccessFunction,
      onError: captchaExampleErrorFunction
    });



captchaExampleSuccessFunction(wafToken) {
        window.AwsWafIntegration.fetch(this.captchaVerifiedFn());
    },

I need to call captchaVerifiedFn() after user completes puzzle.

Any help would be appreciated.

答案1

得分: 1

captchaExampleSuccessFunction(wafToken) 是成功指示。在渲染验证码并用户成功完成后,会调用 captchaExampleSuccessFunction(wafToken),其中包括一个令牌。如果验证码验证失败,它不会被调用。如果你想在成功完成验证码和提交数据到后端之间进行一些操作,你可以使用 AwsWafIntegration,它有一些检查令牌的方法,如 checkForceRefreshfetchforceRefreshTokengetTokenhasToken

此外,根据你最后一句话的意思,你说:“在用户完成拼图后,我需要调用 captchaVerifiedFn()。”难道你不能将 captchaVerifiedFn 移出 fetch 外面,像这样:

captchaExampleSuccessFunction(wafToken) {
    this.captchaVerifiedFn();
},
英文:

captchaExampleSuccessFunction(wafToken) is the success indicator. After you Render the captcha and the user completes it successfully captchaExampleSuccessFunction(wafToken) gets called which includes a token. It would not get called if the capture failed. If you want to do things between the successful captcha completion and you submitting data to your backend you can use AwsWafIntegration which has methods to check the token such as checkForceRefresh, fetch, forceRefreshToken, getToken, hasToken

Also reading your last line you say "I need to call captchaVerifiedFn() after user completes puzzle." cant you just move the captchaVerifiedFn outside of the fetch captchaExampleSuccessFunction(wafToken) {
this.captchaVerifiedFn();
},

huangapple
  • 本文由 发表于 2023年7月24日 18:40:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76753672.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定