Commit 32eadf8739d2abb853a29b2392bd93c534bae847

Authored by Nicolás Guarnieri
1 parent 88404964dd

sin console

Showing 1 changed file with 0 additions and 1 deletions   Show diff stats
src/js/controller.js
1 angular.module('focaLogin') 1 angular.module('focaLogin')
2 .controller('focaLoginController', [ 2 .controller('focaLoginController', [
3 '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 3 '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService',
4 function($scope, focaLoginService, $location, $cookies, focaModalService) { 4 function($scope, focaLoginService, $location, $cookies, focaModalService) {
5 $scope.paso = 1; 5 $scope.paso = 1;
6 $scope.enviar = function() { 6 $scope.enviar = function() {
7 focaLoginService.login($scope.usuario).then(function(datos) { 7 focaLoginService.login($scope.usuario).then(function(datos) {
8 8
9 if (datos.data.chofer.id) { 9 if (datos.data.chofer.id) {
10 $cookies.put('chofer', datos.data.chofer.id); 10 $cookies.put('chofer', datos.data.chofer.id);
11 } else if (datos.data.vendedorCobrador.CodVen) { 11 } else if (datos.data.vendedorCobrador.CodVen) {
12 $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen); 12 $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen);
13 } else { 13 } else {
14 focaModalService.alert('Existe un error con el usuario ingresado'); 14 focaModalService.alert('Existe un error con el usuario ingresado');
15 return; 15 return;
16 } 16 }
17 17
18 18
19 $cookies.put('token', datos.data.token); 19 $cookies.put('token', datos.data.token);
20 $location.path('/'); 20 $location.path('/');
21 console.info(focaLoginService.getLoginData());
22 $scope.$emit('blur'); 21 $scope.$emit('blur');
23 }, function(error) { 22 }, function(error) {
24 if (error.status === 401) { 23 if (error.status === 401) {
25 focaModalService.alert('El usuario o la contraseña han sido mal introducidos'); 24 focaModalService.alert('El usuario o la contraseña han sido mal introducidos');
26 } 25 }
27 26
28 if(error.status === -1) { 27 if(error.status === -1) {
29 focaModalService.alert('Sin servicio'); 28 focaModalService.alert('Sin servicio');
30 return; 29 return;
31 } 30 }
32 }); 31 });
33 }; 32 };
34 $scope.irPaso = function(numeroPaso) { 33 $scope.irPaso = function(numeroPaso) {
35 $scope.paso = numeroPaso; 34 $scope.paso = numeroPaso;
36 }; 35 };
37 } 36 }
38 ]) 37 ])
39 .controller('focaLogoutController', [ 38 .controller('focaLogoutController', [
40 '$cookies', '$location', 39 '$cookies', '$location',
41 function($cookies, $location) { 40 function($cookies, $location) {
42 $cookies.remove('chofer'); 41 $cookies.remove('chofer');
43 $cookies.remove('vendedorCobrador'); 42 $cookies.remove('vendedorCobrador');
44 $cookies.remove('token'); 43 $cookies.remove('token');
45 //Cierra ventana 44 //Cierra ventana
46 window.open('', '_self', ''); //bug fix 45 window.open('', '_self', ''); //bug fix
47 window.close(); 46 window.close();
48 $location.path('/login'); 47 $location.path('/login');
49 } 48 }
50 ]); 49 ]);
51 50