recatpcha simplified, not depending on external modules

parent 19a063f2
......@@ -13,7 +13,6 @@
"jquery-timeago": "1.4.x",
"angular-translate": "~2.6.0",
"angular-translate-loader-static-files": "~2.6.1",
"angular-re-captcha": "~0.2.0",
"angular-bootstrap": "~0.12.1",
"angular-file-upload": "~1.1.5",
"ng-file-upload": "~3.2.4",
......@@ -29,8 +28,7 @@
"angular-chart.js": "latest",
"ng-lodash": "~0.3.0",
"bootstrap-filestyle": "~1.2.1",
"ngMask": "angular-mask#~3.1.1",
"angular-recaptcha": "~4.0.1"
"ngMask": "angular-mask#~3.1.1"
},
"resolutions": {
"angular": ">=1 <1.3.0",
......
......@@ -41,6 +41,7 @@
"cannot_delete_instruction": "Instruction could not be deleted, maybe due to existing recorded sessions.",
"categories": "Categories",
"category_pictograms": "Category's pictograms",
"captcha_requested": "Captcha must be validated",
"change_password": "Change password",
"change_cat_picto": "Change category pictogram",
"change_picture": "Change picture",
......
......@@ -41,6 +41,7 @@
"cannot_delete_instruction": "No se pudo eliminar la instrucción, tal vez porque existen sesiones asociadas.",
"categories": "Categorías",
"category_pictograms": "Pictogramas de la categoría",
"captcha_requested": "Debe validar el captcha",
"change_password": "Cambiar contraseña",
"change_cat_picto": "Cambiar pictograma de la categoría",
"change_picture": "Cambiar fotografía",
......
......@@ -8,6 +8,7 @@
<link rel="icon" href="img/logo_pictogram.png" type='image/png'>
<script src="js/libs.js"></script>
<script src="js/main.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body ng-controller="MainCtrl">
<toast></toast>
......
......@@ -29,15 +29,16 @@ dashboardApp.constant('CONSTANTS', {
});
/* reCaptcha configuration */
/*
dashboardApp.config(['vcRecaptchaServiceProvider', function(vcRecaptchaServiceProvider){
vcRecaptchaServiceProvider.setSiteKey('6LdLjh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6');
vcRecaptchaServiceProvider.setSiteKey('6LdGOBMUAAAAAJ6uYWb8d952TOR2knwbAem8TKJ8');
vcRecaptchaServiceProvider.setTheme('light');
//vcRecaptchaServiceProvider.setStoken('--- YOUR GENERATED SECURE TOKEN ---')
vcRecaptchaServiceProvider.setSize('normal');
//vcRecaptchaServiceProvider.setType('---- audio or image ----')
vcRecaptchaServiceProvider.setLang('es-es');
}]);
*/
/* Toast (notification) configuration */
dashboardApp.config(['ngToastProvider', function (ngToast) {
......
......@@ -7,7 +7,6 @@ dashboardControllers.controller('LoginSettingPasswordCtrl', function LoginSettin
$scope,
$http,
$window,
reCAPTCHA,
$translate,
$location,
config,
......@@ -25,9 +24,6 @@ dashboardControllers.controller('LoginSettingPasswordCtrl', function LoginSettin
changePasswordForm.$invalid = true;
};
$scope.reset();
reCAPTCHA.setPublicKey('6LdLjh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6');
if ($stateParams.token)
$scope.show_change_form = true;
else
......@@ -37,6 +33,12 @@ dashboardControllers.controller('LoginSettingPasswordCtrl', function LoginSettin
* Handles user submission of request for password change
*/
$scope.request_change_password = function () {
if (grecaptcha.getResponse().length == 0) {
ngToast.danger({ content: $translate.instant('captcha_requested') });
return;
}
if (!$scope.requestChangePasswordForm.$valid)
return;
......
......@@ -31,32 +31,6 @@ function SignInCtrl($scope,
$scope.reset();
//
// reCaptcha functions
//
/*
$scope.recaptcha = {
lang : $translate.use(),
response : null,
widgetId : null,
setResponse: function (response) {
console.info('Response available');
$scope.recaptcha.response = response;
},
setWidgetId: function (widgetId) {
console.info('Created widget ID: %s', widgetId);
$scope.recaptcha.widgetId = widgetId;
},
cbExpiration: function() {
console.info('Captcha expired. Resetting response object');
vcRecaptchaService.reload($scope.recaptcha.widgetId);
$scope.recaptcha.response = null;
}
};*/
// Form submit
$scope.signin = function () {
// Validate email match
......@@ -81,6 +55,11 @@ function SignInCtrl($scope,
return;
}
if (grecaptcha.getResponse().length == 0) {
ngToast.danger({ content: $translate.instant('captcha_requested') });
return;
}
if (!$scope.signInForm.$valid)
return;
......
......@@ -26,9 +26,9 @@
<input type="email" class="form-control" id="email" placeholder="{{ 'your_email' | translate}}" required ng-model="email"/>
</div>
<div class="form-group" ng-if="!show_change_form">
<label>Captcha*</label>
<div re-captcha ng-model="captcha_reqchgpass"></div>
<div class="form-group">
<legend>Captcha</legend>
<div class="g-recaptcha" data-sitekey="6LdGOBMUAAAAAJ6uYWb8d952TOR2knwbAem8TKJ8"></div>
</div>
<p class="text-center">
......
......@@ -78,17 +78,15 @@
</fieldset>
<div class="form-group">
<div
vc-recaptcha
key="6LdLjh0TAAAAANblo_KUGNnmRZuIetOkdjdhj1b6"
></div>
<input type="checkbox" ng-model="formdata.disclaimer_accepted">
<span translate>disclaimer_accept</span>
</div>
<div class="form-group">
<input type="checkbox" ng-model="formdata.disclaimer_accepted">
<span translate>disclaimer_accept</span>
<legend>Captcha</legend>
<div class="g-recaptcha" data-sitekey="6LdGOBMUAAAAAJ6uYWb8d952TOR2knwbAem8TKJ8"></div>
</div>
<p class="text-center">
<button type="submit" class="btn btn-primary" ng-disabled="signInForm.$invalid" translate>create_account</button>
</p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment