diff --git a/www/addons/mod/feedback/services/helper.js b/www/addons/mod/feedback/services/helper.js
index 1ab0a761512..c8f3302ac4e 100644
--- a/www/addons/mod/feedback/services/helper.js
+++ b/www/addons/mod/feedback/services/helper.js
@@ -269,7 +269,26 @@ angular.module('mm.addons.mod_feedback')
angular.forEach(items, function(itemData) {
itemData.hasError = false;
- if (itemData.hasvalue) {
+
+ if (itemData.typ == "captcha") {
+ var value = itemData.value || "",
+ name = itemData.typ + '_' + itemData.id,
+ answered = false;
+
+ answered = !!value;
+ responses[name] = 1;
+ responses.recaptcha_challenge_field = itemData.captcha && itemData.captcha.challengehash;
+ responses.recaptcha_response_field = value;
+ responses['g-recaptcha-response'] = value;
+ responses.recaptcha_element = 'dummyvalue';
+
+ if (itemData.required && !answered) {
+ // Check if it has any value.
+ itemData.isEmpty = true;
+ } else {
+ itemData.isEmpty = false;
+ }
+ } else if (itemData.hasvalue) {
var name, value,
nameTemp = itemData.typ + '_' + itemData.id,
answered = false;
@@ -310,23 +329,6 @@ angular.module('mm.addons.mod_feedback')
responses[name] = value;
}
- if (itemData.required && !answered) {
- // Check if it has any value.
- itemData.isEmpty = true;
- } else {
- itemData.isEmpty = false;
- }
- } else if (itemData.typ == "captcha") {
- var value = itemData.value || "",
- name = itemData.typ + '_' + itemData.id,
- answered = false;
-
- answered = !!value;
- responses[name] = 1;
- responses.recaptcha_challenge_field = itemData.captcha && itemData.captcha.challengehash;
- responses.recaptcha_response_field = value;
- responses.recaptcha_element = 'dummyvalue';
-
if (itemData.required && !answered) {
// Check if it has any value.
itemData.isEmpty = true;
diff --git a/www/addons/mod/feedback/templates/form.html b/www/addons/mod/feedback/templates/form.html
index 1639577783b..3bcba2c8b43 100644
--- a/www/addons/mod/feedback/templates/form.html
+++ b/www/addons/mod/feedback/templates/form.html
@@ -55,15 +55,10 @@
diff --git a/www/core/components/login/controllers/emailsignup.js b/www/core/components/login/controllers/emailsignup.js
index 241a0b9c3f9..d87eba473fc 100644
--- a/www/core/components/login/controllers/emailsignup.js
+++ b/www/core/components/login/controllers/emailsignup.js
@@ -26,7 +26,8 @@ angular.module('mm.core.login')
var siteConfig,
modalInitialized = false,
- scrollView = $ionicScrollDelegate.$getByHandle('mmLoginEmailSignupScroll');
+ scrollView = $ionicScrollDelegate.$getByHandle('mmLoginEmailSignupScroll'),
+ recaptchaV1Enabled = false;
$scope.siteurl = $stateParams.siteurl;
$scope.data = {};
@@ -74,6 +75,8 @@ angular.module('mm.core.login')
$scope.settings = settings;
$scope.countries = $mmUtil.getCountryList();
$scope.categories = $mmLoginHelper.formatProfileFieldsForSignup(settings.profilefields);
+ recaptchaV1Enabled = !!(settings.recaptchapublickey && settings.recaptchachallengehash &&
+ settings.recaptchachallengeimage);
if (settings.defaultcity && !$scope.data.city) {
$scope.data.city = settings.defaultcity;
@@ -81,7 +84,9 @@ angular.module('mm.core.login')
if (settings.country && !$scope.data.country) {
$scope.data.country = settings.country;
}
- $scope.data.recaptcharesponse = ''; // Reset captcha.
+ if (recaptchaV1Enabled) {
+ $scope.data.recaptcharesponse = ''; // Reset captcha.
+ }
$scope.namefieldsErrors = {};
angular.forEach(settings.namefields, function(field) {
@@ -123,8 +128,8 @@ angular.module('mm.core.login')
});
};
- // Request another captcha.
- $scope.requestCaptcha = function(ignoreError) {
+ // Request another captcha (V1).
+ $scope.requestCaptchaV1 = function(ignoreError) {
var modal = $mmUtil.showModalLoading();
getSignupSettings().catch(function(err) {
if (!ignoreError && err) {
@@ -164,10 +169,13 @@ angular.module('mm.core.login')
params.redirect = $mmLoginHelper.prepareForSSOLogin($scope.siteurl, service, siteConfig.launchurl);
}
- if ($scope.settings.recaptchachallengehash && $scope.settings.recaptchachallengeimage) {
- params.recaptchachallengehash = $scope.settings.recaptchachallengehash;
+ // Get the recaptcha response (if needed).
+ if ($scope.data.recaptcharesponse) {
params.recaptcharesponse = $scope.data.recaptcharesponse;
}
+ if ($scope.settings.recaptchachallengehash) {
+ params.recaptchachallengehash = $scope.settings.recaptchachallengehash;
+ }
// Get the data for the custom profile fields.
$mmUserProfileFieldsDelegate.getDataForFields(fields, true, 'email', $scope.data).then(function(fieldsData) {
@@ -180,20 +188,29 @@ angular.module('mm.core.login')
$ionicHistory.goBack();
} else {
if (result.warnings && result.warnings.length) {
- $mmUtil.showErrorModal(result.warnings[0].message);
+ var error = result.warnings[0].message;
+ if (error == 'incorrect-captcha-sol') {
+ error = $translate.instant('mm.login.recaptchaincorrect');
+ }
+
+ $mmUtil.showErrorModal(error);
} else {
$mmUtil.showErrorModal('mm.login.usernotaddederror', true);
}
- // Error sending, request another capctha since the current one is probably invalid now.
- $scope.requestCaptcha(true);
+ if (recaptchaV1Enabled) {
+ // Error sending, request another capctha since the current one is probably invalid now.
+ $scope.requestCaptchaV1(true);
+ }
}
});
}).catch(function(error) {
$mmUtil.showErrorModalDefault(error && error.error, 'mm.login.usernotaddederror', true);
- // Error sending, request another capctha since the current one is probably invalid now.
- $scope.requestCaptcha(true);
+ if (recaptchaV1Enabled) {
+ // Error sending, request another capctha since the current one is probably invalid now.
+ $scope.requestCaptchaV1(true);
+ }
}).finally(function() {
modal.dismiss();
});
diff --git a/www/core/components/login/lang/en.json b/www/core/components/login/lang/en.json
index 0d40aa9fc49..94bfcc156ae 100644
--- a/www/core/components/login/lang/en.json
+++ b/www/core/components/login/lang/en.json
@@ -58,6 +58,8 @@
"problemconnectingerrorcontinue": "Double check you've entered the address correctly and try again.",
"profileinvaliddata": "Invalid value",
"recaptchachallengeimage": "reCAPTCHA challenge image",
+ "recaptchaexpired": "Verification expired. Answer the security question again.",
+ "recaptchaincorrect": "The security question answer is incorrect.",
"reconnect": "Reconnect",
"reconnectdescription": "Your authentication token is invalid or has expired. You have to reconnect to the site.",
"reconnectssodescription": "Your authentication token is invalid or has expired. You have to reconnect to the site. You need to log in to the site in a browser window.",
diff --git a/www/core/components/login/templates/emailsignup.html b/www/core/components/login/templates/emailsignup.html
index 0c6c8cf2dcd..7ec58ed5835 100644
--- a/www/core/components/login/templates/emailsignup.html
+++ b/www/core/components/login/templates/emailsignup.html
@@ -59,18 +59,10 @@
{{ 'mm.core.answered' | translate }}
+{{ 'mm.login.recaptchaexpired' | translate }}
+