How to implement Captcha code in Angular8

Posted by Manideepgoud under Angular on 8/6/2020 | Points: 10 | Views : 831 | Status : [Member] | Replies : 1
Hi Sheo sir,

Need some help in implementing captcha code(generating captcha code with refresh button) in Angular8.

Can some one help me in this please.




Responses

Posted by: Ishan7 on: 11/23/2020 [Member] Starter | Points: 25

Up
1
Down
Step 1: Install Angular Captcha Module
npm install angular-captcha --save

app.module.ts
// import the Angular Captcha Module 
import { BotDetectCaptchaModule } from 'angular-captcha';

@NgModule({
imports: [
...
BotDetectCaptchaModule
],
...
})



Step 2:Set the captchaEndpoint in Your App's Frontend
import { CaptchaComponent } from 'angular-captcha'; 

export class YourFormWithCaptchaComponent {

ngOnInit(): void {
this.captchaComponent.captchaEndpoint =
'https://your-app-backend-hostname.your-domain.com/simple-captcha-endpoint';
}


Step 3:Displaying the Captcha Challenge in Your Form
<botdetect-captcha captchaStyleName="yourFirstCaptchaStyle"></botdetect-captcha>  
<input id="userCaptchaInput"
name="userCaptchaInput"
ngModel
#userCaptchaInput="ngModel"
type="text" >


Step 4:Validate C#
SimpleCaptcha yourFirstCaptcha = new SimpleCaptcha();
bool isHuman = yourFirstCaptcha.Validate(userEnteredCaptchaCode, captchaId);


Manideepgoud, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response