[英]How do I implement ReCaptcha in a Single Page Application (SPA)
I have a Single Page Application (SPA) I would like to add ReCaptcha to.我有一个单页应用程序 (SPA),我想向其中添加 ReCaptcha。 This application is hosted using IIS as flat Html, Css & Javascript, this SPA in turn talks to a separate REST server (using CORS) for all dynamic content.
此应用程序使用 IIS 作为平面 Html、Css 和 Javascript 托管,此 SPA 又与单独的 REST 服务器(使用 CORS)对话以获取所有动态内容。
The REST server is written using ASP.net WebAPI. REST 服务器是使用 ASP.net WebAPI 编写的。 The problem is;
问题是; all examples I have seen of ReCaptcha all use ASP.net MVC (or other languages) to inject html into the webpage, I cannot modify the webpage using ASP.net in this manor.
我见过的所有ReCaptcha的例子都是使用ASP.net MVC(或其他语言)将html注入到网页中,我无法在这个庄园使用ASP.net修改网页。 Hopefully someone else has had the same problem.
希望其他人也遇到过同样的问题。
I am really looking for some 2 parts, first the HTML that belongs on the client, and secondly the Controller that would be on the REST Server to verify with google.我真的在寻找一些 2 部分,首先是属于客户端的 HTML,其次是将在 REST 服务器上与谷歌验证的控制器。 Even if this is in another language that I can convert, this will be useful!
即使这是我可以转换的另一种语言,这也会很有用!
看起来我想要的只是使用没有插件的 reCaptcha ( https://developers.google.com/recaptcha/docs/display )
I have used ngx-captcha with my angular project.我在我的 angular 项目中使用了 ngx-captcha。 Here's how I kept my submit button disabled until recaptcha checkbox is checked.
这是我如何禁用提交按钮,直到选中 recaptcha 复选框。
//code <ngx-recaptcha2 (success)="handleSuccess($event)" #captchaElem [siteKey]="siteKey" formControlName="recaptcha"> </ngx-recaptcha2>
once captcha is filled , it emits a success event , so use it in a method to make a variable true/false based on which you can enable/disable submit button一旦验证码被填充,它就会发出一个成功事件,所以在一个方法中使用它来创建一个变量真/假,你可以根据它启用/禁用提交按钮
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.