Reset password recaptcha error on provider portal
# support
a
Hello. I am currently running our provider portal with the backend being hosted by Medplum. I am currently experiencing an issue with reCAPTCHA when using Medplum's
ResetPasswordPage.tsx
example: https://github.com/medplum/medplum/blob/main/packages/app/src/ResetPasswordPage.tsx Here’s the setup and problem: - On my GCP project, I've created a reCAPTCHA token. I have "whitelisted" my app's URL,
localhost
, etc. for this token. - On the [Medplum Admin Sites](https://app.medplum.com/admin/details) page, I’ve provided the "Recaptcha Site Key" and "Recaptcha Secret Key" that correspond to this token. - When I log the
recaptchaSiteKey
to the browser console, I can see that it is correct. - When I attempt to reset my password via the Medplum frontend, I receive a "Recaptcha failed" error (please see the full error logged to browser console at the end of this message*). - However, when I log the
recaptchaToken
to my browser console and use it in a
curl
request on my VM's CLI, **the verification succeeds**:
curl -X POST -d "secret=RECAPTCHA_SECRET_KEY&response=RECAPTCHA_TOKEN" https://www.google.com/recaptcha/api/siteverify
Given that the
curl
request works, it seems like this issue might be occurring at the backend level. Could someone please help clarify what might be going wrong here? *Full recaptcha error logged to browser console:
Copy code
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "text": "Recaptcha failed"
      }
    }
  ],
  "extension": [
    {
      "url": "https://medplum.com/fhir/StructureDefinition/tracing",
      "extension": [
        {
          "url": "requestId",
          "valueId": "[redacted]"
        },
        {
          "url": "traceId",
          "valueId": "[redacted]"
        }
      ]
    }
  ]
}
Figured out the issue myself. For anyone else in the future who is running into this issue, the
POST
statement on [line 42 of ResetPasswordPage.tsx](https://github.com/medplum/medplum/blob/main/packages/app/src/ResetPasswordPage.tsx#L42) should include
recaptchaSiteKey
in the
body
arg. In other words:
Copy code
.post('auth/resetpassword', { ...formData, recaptchaToken, recaptchaSiteKey })
159 Views