PageSourceSearch

https://clientes.criteria.com.ar/vbhome/ScriptsLogin16.0.0/loginController-16.0.0.js

js criteria.com.ar collected 2026-09-24 10:43:40 UTC 11,986 bytes, 334 lines download raw bytes

1'use strict';
2app.controller('loginController', ['$scope', '$rootScope', 'authService', 'helpersService', '$location', 'recoveryAccessService', 'resourceService', '$http', '$q', '$mdDialog', 'unisyncSettings', 'storageService', '$routeParams', 'misDatosService', '$filter', '$injector', function ($scope, $rootScope, authService, Unisync, $location, recoveryAccessService, resourceService, $http, $q, $mdDialog, unisyncSettings, storageService, $routeParams, misDatosService, $filter, $injector) {
3
4    var userService = $injector.get("userService");
5
6  $scope.paramsLoaded = false;
7    initParameters();
8    var _authentication = authService.getAuthData();
9
10    
11
12
13    var _loginData = {
14        userName: '',
15        password: ''
16  };
17
18  var _loginDataEncript = {
19    userName: '',
20    password: ''
21  };
22
23  function initParameters() {
24    $rootScope.appPromises.recover = resourceService.getParametrosAll().then(function (response) {
25
26      angular.forEach(response.data, function (item) {
27        switch (item.C) {
28          case "URSITE":
29            $scope.userNoRegisAccess = item.VB;
30            break;
31          case "DESFOR":
32            $scope.descargaForm = item.VB;
33            break;
34          case "TXTDES":
35            $scope.textoTituloRegistroOffLine = item.VB;
36            break;
37          case "HABREG":
38            $scope.habilitaRegistro = item.VB;
39            break;
40          case "USNRTX":
41            $scope.TextoUsuarioNoRegistrado = item.VT;
42            break;
43          case "DURBLO":
44            $scope.ParamDuracionBloqueo = item.VN;
45            break;
46          case "URLLOG":
47                $scope.paramUrlLogin = item.VT;
48            break;
49                URLLOG
50        }
51      });
52        $scope.paramsLoaded = true;
53
54
55        var guid = $routeParams.uid;
56        if (guid != null) {
57            //Update SolicitudReg
58            
59            $rootScope.appPromises.recover = misDatosService.MailCheck(guid).then(function (response) {
60                    if (response.data == "OK" || response.data =="EXPIRED" ) {
61                        $rootScope.showAlert($filter('translate')('MAILCHECKOK'), angular.noop());
62                    }                    
63                }, function (response) {
64                    
65                }
66            );
67        }
68
69
70    }, function (response) {
71        $scope.TextoUsuarioNoRegistrado = "";
72    });
73
74  }
75
76  var doLogin = function (captchaToken) {
77   
78    if ($scope.logInForm.$valid) {
79
80      //Deshabilito controles de login mientras se ejecuta login
81      _disableControls(true);
82
83      $rootScope.appPromises.login = authService.getPK().then(
84        function (response) {
85
86          $scope.loginDataEncript.userName = $scope.loginData.userName;
87          $scope.loginDataEncript.password = $scope.loginData.password;
88
89          //Encript
90          if (response != "") {
91            var encrypt = new JSEncrypt();
92            var pubKey = response;
93            encrypt.setPublicKey(pubKey);
94
95            var encrypted = encrypt.encrypt($scope.loginData.password);
96            $scope.loginDataEncript.password = encrypted;
97            encrypted = encrypt.encrypt($scope.loginData.userName);
98            $scope.loginDataEncript.userName = encrypted;
99
100          }
101
102          $rootScope.appPromises.login = authService.login($scope.loginDataEncript, $scope.loginData.userName, captchaToken).then(
103              function (response) {
104
105                  
106
107                  $rootScope.appPromises.login = userService.getByIdToken(authService.getAuthData().userID, false, authService.getAuthData().token, authService.getAuthData().refreshToken, authService.getAuthData().refreshToken.userID).then(function (response) {
108                      $rootScope.userData = response.data;
109                      
110                      //Si el usuario tiene doble factor, lo redirijo a la pantalla de doble factor
111                      if (response.data.DobleFactor != true) {                          
112                           window.location = 'desktop.html';
113                      } else {
114
115                          //Si es correcto, redirecciono
116                          $mdDialog.show({
117                              templateUrl: 'Unisync/Views/dobleFactorCheck.html',
118                              controller: ['$scope', '$mdDialog', '$injector', function ($scope, $mdDialog, $injector) {
119
120                                  $scope.otp = ['', '', '', '', '', ''];
121
122                                  $scope.moveNext = function (index) {
123                                      // Acepta solo números
124                                      $scope.otp[index] = $scope.otp[index].replace(/[^0-9]/g, '');
125
126                                      if ($scope.otp[index].length === 1 && index < 5) {
127                                          const nextInput = document.getElementById('otp-' + (index + 2));
128                                          if (nextInput) {
129                                              nextInput.focus();
130                                          }
131                                      }
132                                  };
133
134                                  $scope.DobleFactorCodigo = "";
135                                  $scope.ShowMensajeError = false;
136
137                                  $scope.checkCodigo = function () {
138
139                                      $scope.DobleFactorCodigo = $scope.otp.join('');
140                                      $rootScope.appPromises.login = userService.CheckDobleFactorToken(response.data.DobleFactorKey, $scope.DobleFactorCodigo, authService.getAuthData().token, authService.getAuthData().refreshToken, authService.getAuthData().refreshToken.userID).then(function (response) {
141                                          var CodOk = response.data;
142                                          //Si esta Ok. Guardo la configuracion
143                                          if (CodOk == true) {
144                                              $scope.ShowMensajeError = false;
145                                              window.location = 'desktop.html';
146                                          } else {
147                                              $scope.ShowMensajeError = true;
148                                              //$rootScope.showMessageError("El codigo ingresado es incorrecto");
149                                          }
150
151                                      }, function (error) {
152                                          //$rootScope.showMessageError(error.data);
153                                      });
154
155                                  };
156                              }],
157                          });
158                          
159                      }
160
161
162                  }, function (error) {
163                  });
164
165                  
166
167                  
168            },
169            function (err) {
170
171                _disableControls(false);
172              //Sino, muestro error
173              //Si el bloqueo lo tiene q sacar un admnin cambio msj
174              if (err.CodError == 1) {
175                err.Msj = "El usuario no posee cuentas habilitadas para consulta";
176              }
177              if ($scope.ParamDuracionBloqueo == "" && err.CodError == 12) {
178                err.Msj = "ATENCION. El usuario se encuentra bloqueado, comuníquese con su Oficial de Cuenta.";
179              }
180              try {
181                if (err.DatosAux.timeforlogon) {
182                  var time = 0;
183                  try {
184                    time = Math.abs(parseInt(err.DatosAux.timeforlogon));
185                  }
186                  catch (err) {
187                    time = 0;
188                    err.Msj += ". Puede intentarlo nuevamente en menos de 1 minuto."
189                  }
190                  var mintxt = "minuto";
191                  if (time > 1) {
192                    mintxt += "s";
193                  }
194                  err.Msj += ". Puede intentarlo nuevamente en " + time + " " + mintxt + "."
195                }
196              }
197              catch (err) {
198
199              }
200
201
202                var msjError = $filter('translate')(err.CodError);
203
204                if (msjError == err.CodError) {
205                    msjError = err.Msj;
206                }
207
208                if (err.CodError == "ADM0018") {
209                    msjError = err.Msj;
210                }
211
212                $rootScope.showAlert(msjError, function () {
213                    $rootScope.userNameLogin = $scope.loginData.userName; 
214                    
215                //Se el error es de tipo UsuarioClaveNoValido, PasswordExpiredException, WeakPassword
216                if (err.CodError == "31" || err.CodError == "28" || err.CodError == "30" || err.CodError == "26") {
217                  $location.path('/cambiarContrasenia');
218                }
219
220                //NuevoAdmin
221                if (err.CodError == "SEC0006") {
222                  $location.path('/cambiarContrasenia');
223                }
224
225              });
226            }
227          ).then(function () {
228            //Habilito los controles
229            _disableControls(false);
230          });
231        },
232        function (err) {
233
234        });
235    }
236    else {
237      //Trigger validation for every input in form
238      for (var field in $scope.logInForm) {
239        // $setTouched for every not special input 
240        if (field[0] != '$' && $scope.logInForm[field].$pristine) {
241          $scope.logInForm[field].$setTouched(true);
242        }
243      }
244    }
245  }
246
247  var _logIn = function () {
248
249    if ($scope.requirecaptcha) {
250      grecaptcha.ready(function () {
251        grecaptcha.execute(unisyncSettings.captchaPK, { action: 'logInForm' }).then(function (token) {
252          doLogin(token);
253        });
254      });
255    } else {
256      doLogin("");
257    }
258        
259    };
260
261  var _logOut = function () {
262
263
264      //Remove all the local storage
265      storageService.removeAll();
266
267      _authentication.isAuth = false;
268      _authentication.userName = "";
269      _authentication.refreshToken = "";
270      _authentication.userType = "";
271      _authentication.accountLength = "";
272
273      //Deslogueo
274      authService.logOut();
275      window.location = 'login.html';
276
277
278
279        
280    };
281
282    var _disableControls = function (disable) {
283        var $controls = $('#login input, #login button');
284
285        if (disable) {
286            $controls.attr('disabled', 'disabled');
287        }
288        else {
289            $controls.removeAttr('disabled');
290        }
291    };
292
293  var _recoveryAccess = function () {
294
295            $rootScope.appPromises.recover = recoveryAccessService.RecoveryEnabled().then(function (response)
296        {
297            $scope.reconverVisible = response;
298            }, function (response)
299            {
300                $scope.reconverVisible = false;
301            }
302        );
303    };
304
305    $scope.showRequerimientos = function () {
306
307        $mdDialog.show({
308            templateUrl: 'Unisync/Views/requerimientos.html',
309            controller: ['$scope', '$mdDialog', function ($scope, $mdDialog) {
310                
311
312                $scope.closeDialog = function () {
313                    $mdDialog.cancel();
314                };
315            }],
316        });
317    }
318
319    //Public
320    $scope.authentication = _authentication;
321    $scope.loginData = _loginData;
322    $scope.loginDataEncript = _loginDataEncript;
323  
324    $scope.logIn = _logIn;
325    $scope.logOut = _logOut;
326    $scope.recoveryAccessVisible = _recoveryAccess;
327    $scope.reconverVisible = false;
328    $rootScope.version = getVersion();
329    $scope.txtCamptcha = '';
330    $scope.hdnCaptcha = '';
331    $scope.requirecaptcha = unisyncSettings.captcharequired;
332    //Promises for load indicator
333    $scope.loginPromises = {};
334}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.