Commit 34508b29f1753182ff4082b4ca7140aebd4f1620
Exists in
master
Merge branch 'develop' of git.focasoftware.com:npm/foca-login
Showing
4 changed files
Show diff stats
package.json
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | "description": "Login", |
| 5 | 5 | "main": "dist/foca-login.js", |
| 6 | 6 | "scripts": { |
| 7 | + "refresh": "gulp uglify && cp tmp/foca-login.js ../wrapper-demo/node_modules/foca-login/dist/foca-login.min.js", | |
| 7 | 8 | "test": "echo \"Error: no test specified\" && exit 1", |
| 8 | 9 | "gulp-pre-commit": "gulp pre-commit", |
| 9 | 10 | "postinstall": "gulp uglify && gulp clean-post-install", |
src/js/controller.js
| 1 | 1 | angular.module('focaLogin') |
| 2 | 2 | .controller('focaLoginController', [ |
| 3 | - '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', | |
| 4 | - function($scope, focaLoginService, $location, $cookies, focaModalService, md5) { | |
| 3 | + '$scope', 'focaLoginService', '$location', '$cookies', 'focaModalService', 'md5', 'APP', | |
| 4 | + function ($scope, focaLoginService, $location, $cookies, focaModalService, md5, APP) { | |
| 5 | 5 | $scope.paso = 1; |
| 6 | - $scope.enviar = function() { | |
| 6 | + $scope.hidePassword = true; | |
| 7 | + $scope.enviar = function () { | |
| 7 | 8 | angular.element('#password').blur(); |
| 8 | 9 | focaLoginService.login({ |
| 9 | 10 | idUsuario: $scope.usuario.idUsuario, |
| 10 | - clave: md5.createHash($scope.usuario.clave) | |
| 11 | - }).then(function(datos) { | |
| 11 | + clave: APP != 'facturador' ? md5.createHash($scope.usuario.clave) : | |
| 12 | + $scope.usuario.clave | |
| 13 | + }).then(function (datos) { | |
| 12 | 14 | if (datos.data.chofer && datos.data.chofer.id) { |
| 13 | 15 | $cookies.put('chofer', datos.data.chofer.id); |
| 14 | 16 | $cookies.put('nombreUsuario', datos.data.chofer.nombre); |
| 15 | 17 | } else if (datos.data.vendedorCobrador && datos.data.vendedorCobrador.id) { |
| 16 | 18 | $cookies.put('vendedorCobrador', datos.data.vendedorCobrador.id); |
| 17 | 19 | $cookies.put('nombreUsuario', datos.data.vendedorCobrador.NOM); |
| 20 | + } else if (datos.data.vendedorPlaya) { | |
| 21 | + $cookies.put('vendedorPlaya', datos.data.vendedorPlaya.CodVen); | |
| 22 | + $cookies.put('nombreUsuario', datos.data.vendedorPlaya.NomVen.trim()); | |
| 18 | 23 | } else { |
| 19 | 24 | focaModalService.alert('Existe un error con el usuario ingresado'); |
| 20 | 25 | return; |
| ... | ... | @@ -24,28 +29,29 @@ angular.module('focaLogin') |
| 24 | 29 | $cookies.put('token', datos.data.token); |
| 25 | 30 | $location.path('/'); |
| 26 | 31 | $scope.$emit('blur'); |
| 27 | - }, function(error) { | |
| 32 | + }, function (error) { | |
| 28 | 33 | if (error.status === 401) { |
| 29 | 34 | focaModalService |
| 30 | 35 | .alert('El usuario o la contraseña han sido mal introducidos'); |
| 31 | 36 | } |
| 32 | 37 | |
| 33 | - if(error.status === -1) { | |
| 38 | + if (error.status === -1) { | |
| 34 | 39 | focaModalService.alert('Sin servicio'); |
| 35 | 40 | return; |
| 36 | 41 | } |
| 37 | 42 | }); |
| 38 | 43 | }; |
| 39 | - $scope.irPaso = function(numeroPaso) { | |
| 44 | + $scope.irPaso = function (numeroPaso) { | |
| 40 | 45 | $scope.paso = numeroPaso; |
| 41 | 46 | }; |
| 42 | 47 | } |
| 43 | 48 | ]) |
| 44 | 49 | .controller('focaLogoutController', [ |
| 45 | 50 | '$cookies', '$location', |
| 46 | - function($cookies, $location) { | |
| 51 | + function ($cookies, $location) { | |
| 47 | 52 | $cookies.remove('chofer'); |
| 48 | 53 | $cookies.remove('vendedorCobrador'); |
| 54 | + $cookies.remove('vendedorPlaya'); | |
| 49 | 55 | $cookies.remove('nombreUsuario'); |
| 50 | 56 | $cookies.remove('token'); |
| 51 | 57 | //Cierra ventana |
src/js/service.js
| ... | ... | @@ -20,6 +20,10 @@ angular.module('focaLogin') |
| 20 | 20 | if ($cookies.get('vendedorCobrador')) { |
| 21 | 21 | return {vendedorCobrador: $cookies.get('vendedorCobrador')}; |
| 22 | 22 | } |
| 23 | + | |
| 24 | + if ($cookies.get('vendedorPlaya')) { | |
| 25 | + return {vendedorPlaya: $cookies.get('vendedorPlaya')}; | |
| 26 | + } | |
| 23 | 27 | } |
| 24 | 28 | }; |
| 25 | 29 | } |
src/views/foca-login.html
| 1 | -<div class="login"> | |
| 2 | - <form name="login"> | |
| 3 | - <div class="login-titulo"> | |
| 4 | - <span>Ingreso de usuario</span> | |
| 1 | +<div class="row justify-content-center align-items-center"> | |
| 2 | + <div class="col-12 my-2"> | |
| 3 | + <img src="img/logo.png" class="img-login mx-auto d-block"> | |
| 4 | + </div> | |
| 5 | + <div class="col-8 col-sm-6 col-md-4 col-lg-3 my-2 align-self-stretch"> | |
| 6 | + <div class="bg-gradient-login border-0 rounded shadow-sm text-center"> | |
| 7 | + <form class="p-3 m-0" name="login"> | |
| 8 | + <div class="pt-3 pb-2 mb-3 border-bottom border-white"> | |
| 9 | + <span>Ingreso de usuario</span> | |
| 10 | + </div> | |
| 11 | + <!-- USUARIO --> | |
| 12 | + <label | |
| 13 | + for="user" | |
| 14 | + class="login-small-text m-0"> | |
| 15 | + Usuario | |
| 16 | + </label> | |
| 17 | + <div class="input-group mb-2"> | |
| 18 | + <input | |
| 19 | + class="form-control form-control-sm rounded-pill text-transform-none" | |
| 20 | + type="text" | |
| 21 | + id="user" | |
| 22 | + ng-model="usuario.idUsuario" | |
| 23 | + ng-focus="paso = 1" | |
| 24 | + foca-focus="paso === 1" | |
| 25 | + ng-keyup="$event.keyCode == 13 && irPaso(2)" | |
| 26 | + ladda="loginLoading" | |
| 27 | + teclado-virtual | |
| 28 | + /> | |
| 29 | + </div> | |
| 30 | + <!-- CONTRASEÑA --> | |
| 31 | + <label | |
| 32 | + for="password" | |
| 33 | + class="login-small-text m-0"> | |
| 34 | + Contraseña | |
| 35 | + </label> | |
| 36 | + <div class="input-group mb-2"> | |
| 37 | + <input | |
| 38 | + class="form-control form-control-sm rounded-pill text-transform-none pr-5" | |
| 39 | + id="password" | |
| 40 | + type="{{hidePassword ? 'password' : 'text'}}" | |
| 41 | + ng-model="usuario.clave" | |
| 42 | + foca-focus="paso == 2" | |
| 43 | + ng-keyup="$event.keyCode == 13 && enviar()" | |
| 44 | + ladda="loginLoading" | |
| 45 | + teclado-virtual | |
| 46 | + /> | |
| 47 | + <div class="input-icon px-3"> | |
| 48 | + <div ng-show="!hidePassword" ng-click="hidePassword = !hidePassword"> | |
| 49 | + <i class="fade-in fa fa-eye"></i> | |
| 50 | + </div> | |
| 51 | + <div ng-show="hidePassword" ng-click="hidePassword = !hidePassword"> | |
| 52 | + <i class="fade-in fa fa-eye-slash"></i> | |
| 53 | + </div> | |
| 54 | + </div> | |
| 55 | + </div> | |
| 56 | + <button | |
| 57 | + type="button" | |
| 58 | + ng-click="enviar()" | |
| 59 | + class="btn btn-primary btn-block my-3" | |
| 60 | + ladda="loginLoading"> | |
| 61 | + Ingresar | |
| 62 | + </button> | |
| 63 | + <img | |
| 64 | + src="img/logo-foca.png" | |
| 65 | + class="w-50 rounded mx-auto py-2 d-block"> | |
| 66 | + </form> | |
| 5 | 67 | </div> |
| 6 | - <div class="login-campo"> | |
| 7 | - <label>Usuario</label> | |
| 8 | - <input | |
| 9 | - type = "text" | |
| 10 | - ng-model = "usuario.idUsuario" | |
| 11 | - ng-focus = "paso = 1" | |
| 12 | - foca-focus = "paso == 1" | |
| 13 | - ng-keyup = "$event.keyCode == 13 && irPaso(2)" | |
| 14 | - ladda = "loginLoading" | |
| 15 | - teclado-virtual | |
| 16 | - /> | |
| 17 | - </div> | |
| 18 | - <div class="login-campo"> | |
| 19 | - <label>Contraseña</label> | |
| 20 | - <input | |
| 21 | - id = "password" | |
| 22 | - type = "password" | |
| 23 | - ng-model = "usuario.clave" | |
| 24 | - foca-focus = "paso == 2" | |
| 25 | - ng-keyup = "$event.keyCode == 13 && enviar()" | |
| 26 | - ladda = "loginLoading" | |
| 27 | - teclado-virtual | |
| 28 | - /> | |
| 29 | - </div> | |
| 30 | - <button | |
| 31 | - type="button" | |
| 32 | - ng-click="enviar()" | |
| 33 | - class="login-button btn mt-3 btn-login" | |
| 34 | - ladda="loginLoading" | |
| 35 | - >Ingresar</button> | |
| 36 | - </form> | |
| 68 | + </div> | |
| 37 | 69 | </div> |