From e62494ee1733653205ae07f293e644a59dd12b03 Mon Sep 17 00:00:00 2001
From: Antariksh Mahajan <antarikshmahajan@gmail.com>
Date: Fri, 11 Jun 2021 12:55:28 +0800
Subject: [PATCH] fix(submissions): remove captcha dependence on feature toggle
 (#2143)

---
 .../submit-form.directive.view.html           |  2 +-
 .../forms/services/captcha.client.service.js  | 28 ++++---------------
 2 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html b/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html
index d89d69c3f8..6a6fe749b2 100644
--- a/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html
+++ b/src/public/modules/forms/base/directiveViews/submit-form.directive.view.html
@@ -128,7 +128,7 @@
         <div
           vc-recaptcha
           key="captchaService.publicKey"
-          ng-if="captchaService.create(feature.captcha) && form.hasCaptcha && !disableSubmitButton"
+          ng-if="form.hasCaptcha && !disableSubmitButton"
           size="invisible"
           on-create="captchaService.setWidget(widgetId)"
           on-success="captchaService.onSuccess(response, submitForm)"
diff --git a/src/public/modules/forms/services/captcha.client.service.js b/src/public/modules/forms/services/captcha.client.service.js
index ea3e506a34..476603d08f 100644
--- a/src/public/modules/forms/services/captcha.client.service.js
+++ b/src/public/modules/forms/services/captcha.client.service.js
@@ -26,22 +26,6 @@ function captchaService($window, vcRecaptchaService, Toastr, GTag) {
    */
   this.widgetId = null
 
-  /**
-   * Flag indicating if captcha feature is enabled on app
-   */
-  this.enabled = false
-
-  /**
-   * Set enabled flag
-   * @param {Boolean} enabled
-   */
-  this.create = function (enabled) {
-    // We cannot use setWidget() as an indication that captcha is enabled/disabled because setWidget() will not be called
-    // when captcha is enabled but captcha is blocked
-    this.enabled = enabled
-    return this.enabled
-  }
-
   /**
    * Set widgetId
    * @param {String} widgetId
@@ -77,20 +61,18 @@ function captchaService($window, vcRecaptchaService, Toastr, GTag) {
   }
 
   /**
-   * Expire captcha if captcha enabled
+   * Expire captcha
    */
   this.expire = function () {
-    if (this.enabled) {
-      vcRecaptchaService.reload(this.widgetId)
-      this.response = null
-    }
+    vcRecaptchaService.reload(this.widgetId)
+    this.response = null
   }
 
   /**
-   * Check if response has been set, assuming captcha is enabled
+   * Check if response has been set
    */
   this.isValid = function () {
-    if (this.response || !this.enabled) {
+    if (this.response) {
       return true
     } else {
       return false