Commit 17564a92a36b588f6604cced7bbc5cd3010ecaa4
Exists in
master
Merge branch 'master' into 'master'
Master See merge request !3
Showing
5 changed files
Show diff stats
gulpfile.js
... | ... | @@ -8,7 +8,7 @@ const pump = require('pump'); |
8 | 8 | const rename = require('gulp-rename'); |
9 | 9 | const replace = require('gulp-replace'); |
10 | 10 | const templateCache = require('gulp-angular-templatecache'); |
11 | -const uglify = require('gulp-uglify-es').default; | |
11 | +const uglify = require('gulp-uglify'); | |
12 | 12 | |
13 | 13 | var paths = { |
14 | 14 | srcJS: 'src/js/*.js', |
... | ... | @@ -71,8 +71,6 @@ gulp.task('clean-post-install', function() { |
71 | 71 | .pipe(clean()); |
72 | 72 | }); |
73 | 73 | |
74 | -gulp.task('compile', ['templates', 'uglify']); | |
75 | - | |
76 | 74 | gulp.task('webserver', function() { |
77 | 75 | pump [ |
78 | 76 | connect.server({port: 3000}) |
package.json
... | ... | @@ -5,10 +5,9 @@ |
5 | 5 | "main": "dist/foca-login.js", |
6 | 6 | "scripts": { |
7 | 7 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | - "compile": "gulp compile", | |
9 | 8 | "gulp-pre-commit": "gulp pre-commit", |
10 | - "postinstall": "npm run compile && gulp clean-post-install", | |
11 | - "install-dev": "npm install -D gulp gulp-connect jasmine-core pre-commit angular angular-route angular-cookies bootstrap font-awesome gulp-angular-templatecache gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify-es gulp-replace jquery jshint pump && npm i -D git+http://git.focasoftware.com/npm/foca-directivas.git" | |
9 | + "postinstall": "gulp uglify && gulp clean-post-install", | |
10 | + "install-dev": "npm install -D gulp gulp-connect jasmine-core pre-commit angular angular-route angular-cookies bootstrap font-awesome gulp-angular-templatecache gulp-clean gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-sequence gulp-uglify gulp-replace jquery jshint pump && npm i -D git+https://debo.suite.repo/modulos-npm/foca-directivas" | |
12 | 11 | }, |
13 | 12 | "pre-commit": [ |
14 | 13 | "gulp-pre-commit" |
... | ... | @@ -42,7 +41,7 @@ |
42 | 41 | "foca-directivas": "git+http://git.focasoftware.com/npm/foca-directivas.git", |
43 | 42 | "font-awesome": "^4.7.0", |
44 | 43 | "gulp": "^3.9.1", |
45 | - "gulp-angular-templatecache": "^2.2.5", | |
44 | + "gulp-angular-templatecache": "^2.2.2", | |
46 | 45 | "gulp-clean": "^0.4.0", |
47 | 46 | "gulp-connect": "^5.7.0", |
48 | 47 | "gulp-htmlmin": "^5.0.1", |
... | ... | @@ -50,7 +49,7 @@ |
50 | 49 | "gulp-rename": "^1.4.0", |
51 | 50 | "gulp-replace": "^1.0.0", |
52 | 51 | "gulp-sequence": "^1.0.0", |
53 | - "gulp-uglify-es": "^1.0.4", | |
52 | + "gulp-uglify": "^3.0.1", | |
54 | 53 | "jasmine-core": "^3.3.0", |
55 | 54 | "jquery": "^3.3.1", |
56 | 55 | "jshint": "^2.9.7", |
src/js/app.js
1 | 1 | angular.module('focaLogin', ['ngRoute', 'ngCookies', 'focaDirectivas', 'angular-ladda']) |
2 | 2 | .run(['$rootScope', '$cookies', '$location', function($rootScope, $cookies, $location) { |
3 | 3 | $rootScope.$on('$locationChangeStart', function() { |
4 | - var idUsuario = $cookies.get('idUsuario'); | |
5 | - if(!idUsuario) { | |
4 | + if(!$cookies.get('token')) { | |
6 | 5 | if($location.path() !== '/login') { |
7 | 6 | $location.path('/login'); |
8 | 7 | } |
src/js/controller.js
... | ... | @@ -4,26 +4,27 @@ angular.module('focaLogin') |
4 | 4 | function($scope, focaLoginService, $location, $cookies, focaModalService) { |
5 | 5 | $scope.paso = 1; |
6 | 6 | $scope.enviar = function() { |
7 | - $scope.loginLoading = true; | |
8 | - focaLoginService.login($scope.usuario) | |
9 | - .then(function(datos) { | |
10 | - $scope.loginLoading = false; | |
11 | - $cookies.put('idUsuario', $scope.usuario.idUsuario); | |
12 | - $cookies.put('token', datos.data.token); | |
13 | - $location.path('/'); | |
14 | - $scope.$emit('blur'); | |
15 | - }) | |
16 | - .catch(function(error) { | |
17 | - $scope.loginLoading = false; | |
18 | - if(error.status === 401) { | |
19 | - focaModalService.alert('El usuario y/o la contraseña no coinciden'); | |
20 | - return; | |
21 | - } | |
22 | - if(error.status === -1) { | |
23 | - focaModalService.alert('Sin servicio'); | |
24 | - return; | |
25 | - } | |
26 | - }); | |
7 | + focaLoginService.login($scope.usuario).then(function(datos) { | |
8 | + $cookies.put('token', datos.data.token); | |
9 | + | |
10 | + if (datos.data.chofer) { | |
11 | + $cookies.put('chofer', datos.data.chofer.id); | |
12 | + } else if (datos.data.vendedorCobrador) { | |
13 | + $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.CodVen); | |
14 | + } | |
15 | + | |
16 | + $location.path('/'); | |
17 | + $scope.$emit('blur'); | |
18 | + }, function(error) { | |
19 | + if (error.status === 401) { | |
20 | + focaModalService.alert('El usuario o la contraseña han sido mal introducidos'); | |
21 | + } | |
22 | + | |
23 | + if(error.status === -1) { | |
24 | + focaModalService.alert('Sin servicio'); | |
25 | + return; | |
26 | + } | |
27 | + }); | |
27 | 28 | }; |
28 | 29 | $scope.irPaso = function(numeroPaso) { |
29 | 30 | $scope.paso = numeroPaso; |
... | ... | @@ -33,7 +34,8 @@ angular.module('focaLogin') |
33 | 34 | .controller('focaLogoutController', [ |
34 | 35 | '$cookies', '$location', |
35 | 36 | function($cookies, $location) { |
36 | - $cookies.remove('idUsuario'); | |
37 | + $cookies.remove('chofer'); | |
38 | + $cookies.remove('vendedorCobrador'); | |
37 | 39 | $cookies.remove('token'); |
38 | 40 | //Cierra ventana |
39 | 41 | window.open('', '_self', ''); //bug fix |
src/js/service.js
1 | 1 | angular.module('focaLogin') |
2 | 2 | .service('focaLoginService', [ |
3 | - '$http', 'API_ENDPOINT', | |
4 | - function($http, API_ENDPOINT) { | |
3 | + '$http', 'API_ENDPOINT', 'APP', | |
4 | + function($http, API_ENDPOINT, APP) { | |
5 | 5 | return { |
6 | 6 | login: function(usuario) { |
7 | - return $http.post(API_ENDPOINT.URL + '/usuario/login', usuario); | |
7 | + if (APP) { | |
8 | + APP = '/' + APP; | |
9 | + } | |
10 | + | |
11 | + return $http.post(API_ENDPOINT.URL + '/usuario/login' + APP , usuario); | |
8 | 12 | } |
9 | 13 | }; |
10 | 14 | } |