recatpcha simplified, not depending on external modules

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