Skip to main content

Return to TX Community

Liaison

Configuring CAPTCHA

Configuring CAPTCHA for the Online Application

CAPTCHA was introduced in the 1902.x version of Communities. If you are on version of 1902.x or higher, follow the steps below. If you are on a Communities version PRIOR to 1902.x, follow the steps outlined in February '19 Communities Upgrade. To disable CAPTCHA in versions 1902.x or higher, follow the steps outlined below in Disabling CAPTCHA in the Online Application.

Notes:

  • You MUST complete the steps in a sandbox environment before pushing to production via an Outbound Change Set.
  • When a Sandbox is refreshed, you need to register your Sandbox site with Captcha, i.e., your Captcha keys have to be reset

Step 1: Update the TX_CommunitiesSelfReg visualforce page 

The code is available in the TX_CommunitiesSelfReg page, and you will need to uncomment the code for it to be available:

  1. Navigate to Setup and search for Visualforce Pages.
  2. Select the TX_CommunitiesSelfReg page and click Edit.
  3. Search for the comments of reCaptcha
    • The first one is an html comment, simply remove the <!-- and --> surrounding the line. 
    • The second one is javascript comment surrounded by /* and */, remove those. 
  4. Save your changes.

Step 2: Update the TX_CommunitiesSelfRegController apex class 

The code is available in the TX_CommunitiesSelfRegController apex class, and you will need to uncomment the code for it to be available:

  1. Navigate to Setup and search for Apex Classes.
  2. Select the TX_CommunitiesSelfRegController apex class and click Edit.
  3. Search for isCaptchaEnabled = true; (around line 28)
    1. Remove the comment tag: //
  4. Save your changes.

Step 3: Register for CAPTCHA keys 

  1. Navigate to: https://www.google.com/recaptcha/intro/v3.html
  2. Click Admin Console.
  3. Click the + to Register a New Site.
  4. Enter a Label.
  5. Select reCAPTCHA v2.
  6. Select the “I’m not a robot” Checkbox option.
  7. Add your Domain (this is your Site URL) WITHOUT the http:// portion:

Example: myorg-edition.na00.force.com

Note: Do NOT include anything AFTER the Base URL, such as /portal or /app

  1. Add additional Owners by entering the appropriate Email address.
  2. Click Accept the reCAPTCHA Terms of Service Field.
  3. Click Submit.
  4. You will then see your Site Key and Secret KeyCOPY these values for the next step.

Step 4: Enter Keys into CAPTCHA Setup Edit section

  1. Note your Salesforce URL up to the force.com

Examples: https://na10.salesforce.com OR https://myenhanceddomain.lightning.force.com

  1. Append /apex/TargetX_Base__CaptchaSetup to the URL. 

Examples: https://na10.salesforce.com/apex/TargetX_Base__CaptchaSetup OR https://myenhanceddomain.lightning.force.com/apex/TargetX_Base__CaptchaSetup

  1. Paste in your Site Key and Secret Key from the previous step.
  2. Click Save Keys.

Note: The CAPTCHA Setup page will NOT display your old values to keep them locked down. Save will overwrite your old values with the new ones.

Step 5: Deploy your Change Set 

1. Create an Outbound Change Set Edit section

  1. Navigate to Setup and search for Outbound Change Sets.
  2. Select New​.
  3. Name the Change Set, for example: Online Application Analytics.
  4. Add a Description and Save your changes.
  5. In the Change Set Components section, select Add.
  6. Select a Component Type of Visualforce Page.
  7. Click the checkboxes for the Visualforce pages you updated in the previous steps.

2. Upload your Change Set 

  1. From the Change Set you created above, select the Org you want to send the Change Set to.
  2. Click Upload.

​Note: Uploading the Change Set will send it to the Target Org; it will NOT make changes in your Production Org until you Deploy the Change Set.

3. Validate the Change Set in your Production Org 

  1. Login to your Production Org.
  2. Navigate to Setup and search for Inbound Change Sets.
  3. The Change Set you uploaded should be available under Change Sets Awaiting Deployment.
  4. Click the Change Set you want to deploy.
  5. Click Validate.

4. Deploy the Change Set in your Production Org 

  1. Login to your Production Org.
  2. Navigate to Setup and search for Inbound Change Sets.
  3. The Change Set you uploaded should be available under Change Sets Awaiting Deployment.
  4. Click the Change Set you want to deploy.
  5. Click Deploy.

For additional information on deploying Change Sets, please see Salesforce Help & Training article "Deploying a Change Set"

Once complete, users will see the ReCaptcha checkbox when signing up for your Online Application Community:

reCAPTCHA checkbox on sign up page

Step 6: Enter Keys into CAPTCHA Setup in PRODUCTION Edit section

Once you have deployed your Change Set in  Production, you must enter your Site & Secret Keys specific to production.

  1. Login to your production org.
  2. Note your Salesforce URL up to the salesforce.comExample: https://na10.salesforce.com
  3. Append /apex/TargetX_Base__CaptchaSetup to the URL. Example: https://na10.salesforce.com/apex/TargetX_Base__CaptchaSetup
  4. Paste in your Site Key and Secret Key from the previous step.
  5. Click Save Keys.

Note: The CAPTCHA Setup page will NOT display your old values to keep them locked down. Save will overwrite your old values with the new ones.

Disabling CAPTCHA in the Online Application

You MUST complete the steps in a sandbox environment before pushing to production via an Outbound Change Set.

The code for CAPTCHA is available in the TX_CommunitiesSelfReg page, and you will need to uncomment the code you previously changed to disable CAPTHCA. 

Notes:

  • These steps are for users that manually updated their TX_CommunitiesSelfReg page and are on a Communities version PRIOR to 1902.x. 
  • To disable CAPTCHA in versions 1902.x or higher, follow the steps outlined in Configuring CAPTCHA for the Online Application.
  1. Navigate to Setup and search for Visualforce Pages.
  2. Select the TX_CommunitiesSelfReg page and click Edit.
  3. Locate the line:

<TargetX_Base:Captcha callback="callback"/>

  1. Comment out the line by adding <!-- at the beginning and --> at the end:
<!-- <TargetX_Base:Captcha callback="callback"/> -->
  1. Locate the line:
<apex:commandButton action="{!registerUser}" styleClass="targetx-button" value="{!$Label.site.submit}" id="submit"/>
  1. CHANGE IT TO:
<apex:commandLink action="{!registerUser}" styleClass="targetx-button" value="{!$Label.site.submit}" id="submit"/>
  1. LOCATE the STYLE tag and Comment it out the line by adding <!-- at the beginning and --> at the end:
<!-- <style>
    input[disabled], input[disabled]:hover {
      background-color: #ddd;
      box-shadow: 0 2px 0 #bbb;
    } 
  </style> -->
  1. LOCATE the Script tag and Comment it out the line by adding <!-- at the beginning and --> at the end:
<!-- $("input[id$=submit]").prop('disabled', true);
function callback() {
  $("input[id$=submit]").prop('disabled', false);
} -->
  1. Save your changes.

  2.  Deploy your Change Set.

Auditing CAPTCHA code for the Online Application

If you have determined during a Communities upgrade that pieces of code related to Captcha are not appearing, follow these instructions to verify/update the CAPTCHA-related Communities code. 

Notes:
Timeline of changes/updates for Captcha:

  • February ‘19 - initial release
  • December ‘19 - code changes for defect fix CL-647
  • April ‘20 - code changes for defect fix CL-811


Compare YOUR code for the following components with the most current code (linked below). Click to Download the file.:


Use an online tool like Text-Compare! to compare YOUR code against the latest version.

Note: Keep in mind that you may see differences if your institution has added customizations.

If you are missing any code other than customizations, you can replace it with the above files and then add your customizations back.

  • Was this article helpful?