Skip to content

captchaId is undefined #10

@AbdullatifJamous891

Description

@AbdullatifJamous891

Hi, I am using angular-captcha version 3.7.4 with Java Spring

I have got this error in Captcha Validation

core.js:6456 ERROR TypeError: Cannot read properties of undefined (reading 'value') at CaptchaComponent.get [as captchaCode] (captcha.component.js:35:1) at CaptchaComponent.get [as userEnteredCaptchaCode] (captcha.component.js:42:1) at ForgetPasswordComponent.validate (forget-password.component.ts:27:55) at ForgetPasswordComponent_Template_button_click_17_listener (forget-password.component.html:33:64) at executeListenerWithErrorHandling (core.js:15281:1) at wrapListenerIn_markDirtyAndPreventDefault (core.js:15319:1) at HTMLButtonElement.<anonymous> (platform-browser.js:560:1) at ZoneDelegate.invokeTask (zone.js:406:1) at Object.onInvokeTask (core.js:28654:1) at ZoneDelegate.invokeTask (zone.js:405:1)

it seems like captchaId is undefined

my code look like this in forget-password.component.ts

` validate(value, valid): void {
let userEnteredCaptchaCode = this.captchaComponent.userEnteredCaptchaCode;
let captchaId = this.captchaComponent.captchaId;

const postData = {
  userEnteredCaptchaCode: userEnteredCaptchaCode,
  captchaId: captchaId
};

// post the captcha data to the backend
this.dataService.postAPI(`${this.baseUrl}/botdetectcaptcha`, postData).subscribe(
  response => {
    if (response.success == false) {
      // captcha validation failed; reload image
      this.captchaComponent.reloadImage();
      // TODO: maybe display an error message, too
    } else {
      // TODO: captcha validation succeeded; proceed with the workflow
    }
  }
)

}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions