Commit 34c331342623eb2e4b42911502db1c836203f899

Authored by Eric Fernandez
1 parent a1a13ea147
Exists in master and in 2 other branches demo, develop

fix

Showing 1 changed file with 2 additions and 2 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 $cookies.put('token', datos.data.token); 8 $cookies.put('token', datos.data.token);
9 9
10 if (datos.data.chofer) { 10 if (datos.data.chofer.id) {
11 $cookies.put('chofer', datos.data.chofer.id); 11 $cookies.put('chofer', datos.data.chofer.id);
12 } else if (datos.data.vendedorCobrador) { 12 } else if (datos.data.vendedorCobrador.CodVen) {
13 $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen); 13 $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen);
14 } 14 }
15 15
16 $location.path('/'); 16 $location.path('/');
17 $scope.$emit('blur'); 17 $scope.$emit('blur');
18 }, function(error) { 18 }, function(error) {
19 if (error.status === 401) { 19 if (error.status === 401) {
20 focaModalService.alert('El usuario o la contraseña han sido mal introducidos'); 20 focaModalService.alert('El usuario o la contraseña han sido mal introducidos');
21 } 21 }
22 22
23 if(error.status === -1) { 23 if(error.status === -1) {
24 focaModalService.alert('Sin servicio'); 24 focaModalService.alert('Sin servicio');
25 return; 25 return;
26 } 26 }
27 }); 27 });
28 }; 28 };
29 $scope.irPaso = function(numeroPaso) { 29 $scope.irPaso = function(numeroPaso) {
30 $scope.paso = numeroPaso; 30 $scope.paso = numeroPaso;
31 }; 31 };
32 } 32 }
33 ]) 33 ])
34 .controller('focaLogoutController', [ 34 .controller('focaLogoutController', [
35 '$cookies', '$location', 35 '$cookies', '$location',
36 function($cookies, $location) { 36 function($cookies, $location) {
37 $cookies.remove('chofer'); 37 $cookies.remove('chofer');
38 $cookies.remove('vendedorCobrador'); 38 $cookies.remove('vendedorCobrador');
39 $cookies.remove('token'); 39 $cookies.remove('token');
40 //Cierra ventana 40 //Cierra ventana
41 window.open('', '_self', ''); //bug fix 41 window.open('', '_self', ''); //bug fix
42 window.close(); 42 window.close();
43 $location.path('/login'); 43 $location.path('/login');
44 } 44 }
45 ]); 45 ]);
46 46