PageSourceSearch

https://coopdigital.febor.coop/cdigital/aplicacion/app/components/…/login-publico/loginPublico-controller.js

js febor.coop collected 2026-10-02 01:54:41 UTC 18,156 bytes, 395 lines download raw bytes

1	
2(function () {
3	
4	'use strict';
5	
6	/*--------------------Inicio Controlador LoginPublico --------------*/
7	angular
8		.module( 'app.publicModulo' )
9		.controller( 'LoginPublicoController', LoginPublicoControllerFunc );
10	
11	/* @ngInject */
12	function LoginPublicoControllerFunc ( $log, $rootScope, $location, Loadfuncion, loginPublicoService )
13	{
14
15		var vm = this;
16		vm.resultado;
17		vm.primaryKey;
18		vm.loginPublicoData;
19		vm.display = 0;
20		vm.displayBack;
21		vm.mensaje = '';
22
23		vm.userdata = {};
24		vm.userdata.adClientId = 0;
25		vm.userdata.username = undefined;
26		vm.userdata.password = '';
27
28		vm.tituloLoginPublico = 'Login';
29		
30		vm.getDescAccion = function() {
31		
32			if(vm.display === 0) { return 'Listado de '; }
33			else if(vm.display === 1) { return 'Adicionar '; }
34			else if(vm.display === 2) { return 'Actualizar '; }
35			else if(vm.display === 3) { return 'Eliminar '; }
36			else if(vm.display === 4) { return 'Consultar '; }
37			else if(vm.display === -1) { return 'Mensajes '; }
38		}
39		
40		/* inicializar */
41		vm.inicializar = function () {
42			vm.display = 0;
43			vm.displayBack = 0;
44			vm.mensaje = '';
45			vm.status = '';
46			vm.statusText = '';
47			vm.validacionesList = [];
48			vm.loginPublicoData = {};
49		}
50		
51		vm.irAdicionar = function() {
52			vm.inicializar();
53			vm.display = 1;
54			vm.displayBack = 1;
55			vm.loginPublicoData.adClientId = $rootScope.objetoUser.adClientId;
56			vm.loginPublicoData.adOrgId = $rootScope.objetoUser.adOrgId;
57			//SI HACE USO DE CHECBOX DEBE INICIALIZAR EN FALSE EJEMPLO: vm.loginPublicoData.NOMBRE_CAMPO='N';
58			$log.debug('cregion-controller irAdicionar vm.loginPublicoData{} ',vm.loginPublicoData);
59		}
60		
61		vm.irActualizar = function() {
62			vm.inicializar();
63			vm.display = 2;
64			vm.displayBack = 2;
65		}
66		
67		vm.irEliminar = function() {
68			vm.inicializar();
69			vm.display = 3;
70			vm.displayBack = 3;
71		}
72		
73		/* seleccionar elemento */
74		vm.seleccionar = function ( index ) {
75			$log.debug('cregion-controller seleccionar index{} ', index);
76			vm.seleccionado = index;
77			vm.loginPublicoData = index;
78		}
79		
80		// listar();
81		
82		
83		/** INICIO METODOS COMUNES CRUD **/
84		
85		/*Se guarda un registro*/
86		vm.guardar = function() {
87			
88			loginPublicoService.guardar( vm.loginPublicoData, $rootScope.objetoUser ).then(requestCompleted);
89			
90			function requestCompleted(dataResponse) {
91				
92				if (dataResponse && dataResponse.resultado && dataResponse.resultado === 'OK') {
93					
94					$log.debug('cregion-controller guardar requestCompleted: dataResponse{OK} ', dataResponse);
95					vm.resultado = dataResponse.objetoVO;
96					vm.mensaje = dataResponse.mensaje;
97					vm.displayBack = 0;
98					listar();
99					
100				} else if (dataResponse) {
101					
102					$log.debug('cregion-controller guardar requestCompleted: dataResponse{ERROR} ', dataResponse);
103					if( dataResponse.data && Object.prototype.toString.call(dataResponse.data) === '[object Array]' ) { vm.validacionesList = dataResponse.data; vm.displayBack = 1; }
104					else if( dataResponse.data && typeof dataResponse.data === 'string' ) { vm.mensaje = dataResponse.data; }
105					vm.displayBack = 1;
106					
107				}
108				vm.display = -1;
109				Loadfuncion.desbanecer();
110			}
111		}
112		
113		
114		/*Se actializa un registro*/
115		vm.actualizar = function(){
116			
117			$log.debug('cregion-controller actualizar  vm.seleccionado{} ', vm.seleccionado);
118			
119			//llamado del servicio de actualizar registro
120			loginPublicoService.actualizar( vm.loginPublicoData, $rootScope.objetoUser ).then(requestCompleted);
121			
122			function requestCompleted(dataResponse) {
123				
124				if (dataResponse && dataResponse.resultado && dataResponse.resultado === 'OK') {
125					
126					$log.debug('cregion-controller actualizar requestCompleted: dataResponse{OK} ', dataResponse);
127					vm.resultado = dataResponse.objetoVO;
128					vm.mensaje = dataResponse.mensaje;
129					vm.displayBack = 0;
130					
131				} else if (dataResponse) {
132					
133					$log.debug('cregion-controller actualizar requestCompleted: dataResponse{ERROR} ', dataResponse);
134					if( dataResponse.data && Object.prototype.toString.call(dataResponse.data) === '[object Array]' ) { vm.validacionesList = dataResponse.data; vm.displayBack = 1; }
135					else if( dataResponse.data && typeof dataResponse.data === 'string' ) { vm.mensaje = dataResponse.data; }
136					vm.displayBack = 2;
137					
138				}
139				vm.display = -1;
140				Loadfuncion.desbanecer();
141			}
142		}
143		
144		
145		/*Se borra un registro*/
146		vm.borrar = function ( ){
147			
148			$log.debug('cregion-controller borrar  vm.seleccionado{} ', vm.seleccionado);
149			
150			//llamado del servicio de borrar registro
151			loginPublicoService.borrar( vm.loginPublicoData, $rootScope.objetoUser ).then(requestCompleted);
152			
153			function requestCompleted(dataResponse) {
154				
155				if (dataResponse && dataResponse.resultado && dataResponse.resultado === 'OK') {
156					
157					$log.debug('cregion-controller borrar requestCompleted: dataResponse{OK} ', dataResponse);
158					vm.loginPublicoList.splice(vm.seleccionado,1);
159					vm.mensaje = dataResponse.mensaje;
160					vm.displayBack = 0;
161					
162				} else if (dataResponse) {
163					
164					$log.debug('cregion-controller borrar requestCompleted: dataResponse{ERROR} ', dataResponse);
165					if( dataResponse.data && Object.prototype.toString.call(dataResponse.data) === '[object Array]' ) { vm.validacionesList = dataResponse.data; vm.displayBack = 1; }
166					else if( dataResponse.data && typeof dataResponse.data === 'string' ) { vm.mensaje = dataResponse.data; }
167					vm.displayBack = 3;
168					
169				}
170				vm.display = -1;
171				Loadfuncion.desbanecer();
172			}
173		}
174		
175		
176		/*Se consulta un registro*/
177		vm.consultar = function(){
178			
179			$log.debug('cregion-controller consultar  vm.seleccionado{} ', vm.seleccionado);
180			
181			// variable que captura el id de loginPublico
182			vm.primaryKey = vm.loginPublicoData.loginPublicoId;
183			
184			//llamado del servicio de consultar registro
185			loginPublicoService.consultar( vm.primaryKey, $rootScope.objetoUser ).then(requestCompleted);
186			
187			function requestCompleted(dataResponse) {
188				
189				if (dataResponse && dataResponse.resultado && dataResponse.resultado === 'OK') {
190					
191					$log.debug('cregion-controller consultar requestCompleted: dataResponse{OK} ', dataResponse);
192					vm.loginPublicoData = dataResponse.objetoVO;
193					vm.mensaje = dataResponse.mensaje;
194					vm.display = 4;
195					vm.displayBack = 0;
196					
197				} else if (dataResponse) {
198					
199					$log.debug('cregion-controller consultar requestCompleted: dataResponse{ERROR} ', dataResponse);
200					if( dataResponse.data && Object.prototype.toString.call(dataResponse.data) === '[object Array]' ) { vm.validacionesList = dataResponse.data; vm.displayBack = 1; }
201					else if( dataResponse.data && typeof dataResponse.data === 'string' ) { vm.mensaje = dataResponse.data; }
202					vm.display = -1;
203					vm.displayBack = 0;
204					
205				}
206				Loadfuncion.desbanecer();
207			}
208		}
209		
210		
211		/*solicitar datos de la lista*/
212		function listar(){
213			
214			vm.display = 0;
215			vm.loginPublicoData = {};
216			vm.loginPublicoData.adClientId = $rootScope.objetoUser.adClientId;
217			vm.loginPublicoData.adOrgId = $rootScope.objetoUser.adOrgId;
218			//vm.loginPublicoData.INICIALIZAR PARA FILTRAR
219			
220			loginPublicoService.listar( vm.loginPublicoData, $rootScope.objetoUser ).then(requestCompleted);
221			
222			function requestCompleted(dataResponse) {
223				
224				$log.debug('cregion-controller consultar requestCompleted: dataResponse{} ', dataResponse);
225				if (dataResponse && dataResponse.resultado && dataResponse.resultado === 'OK') {
226					
227					$log.debug('cregion-controller listar requestCompleted: dataResponse{OK} ', dataResponse);
228					vm.loginPublicoList = dataResponse.resultadosList.resultado;
229					
230				} else if (dataResponse) {
231					
232					$log.debug('cregion-controller listar requestCompleted: dataResponse{ERROR} ', dataResponse);
233					if( dataResponse.data && Object.prototype.toString.call(dataResponse.data) === '[object Array]' ) { vm.validacionesList = dataResponse.data; vm.displayBack = 1; }
234					else if( dataResponse.data && typeof dataResponse.data === 'string' ) { vm.mensaje = dataResponse.data; }
235					vm.display = -1;
236					
237				}
238				vm.displayBack = 0;
239				Loadfuncion.desbanecer();
240			}
241		}
242		/** FINAL METODOS COMUNES CRUD **/
243
244
245		/*  funcion de login    */
246        vm.logearse = function(){
247            
248			Loadfuncion.mostrar();
249			
250			$location.path('/solicitar-credito-temp');
251
252			Loadfuncion.desbanecer();
253           	/* vm.question1 = undefined;
254           	vm.question2 = undefined;
255        	
256        	vm.userdata.adOrgId = V_CoopDig.V_AdOrgId;
257           	$log.debug('public-controller logearse  vm.userdata{} ', vm.userdata);
258			
259			return publicService.Login(vm.userdata).then(requestCompleted);
260			function requestCompleted(dataResponse) {
261
262				$log.debug('public-controller Login requestCompleted: dataResponse{} ', dataResponse);
263				if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'OK') {
264					
265                    // store username and token in local storage to keep user logged in between page refreshes
266                    $localStorage.currentUser = { username:dataResponse.usuario.username, token:dataResponse.usuario.token, adClientId:dataResponse.usuario.adClientId, adOrgId:dataResponse.usuario.adOrgId, identificacion:dataResponse.usuario.identificacion, tipoIdentificacion:dataResponse.usuario.tipoIdentificacion, email:dataResponse.usuario.email, nombre:dataResponse.usuario.nombre, nombres:dataResponse.usuario.nombres, apellidos:dataResponse.usuario.apellidos, ultimoAcceso:dataResponse.usuario.ultimoAcceso, userId:dataResponse.usuario.userId, adApplicationId:dataResponse.usuario.adApplicationId, origenOperacion:dataResponse.usuario.origenOperacion };
267                    
268                    // add jwt token to auth header for all requests made by the $http service
269                    $http.defaults.headers.common.Authorization = dataResponse.usuario.token;
270                    $http.defaults.headers.Authorization = dataResponse.usuario.token;
271                    
272    	           	$rootScope.objetoUser = dataResponse.usuario;//datos de login 
273    	           	
274                    $log.debug('public-controller OK $rootScope.objetoUser: ',$rootScope.objetoUser);
275                    
276                    V_CoopDig.V_ProductosList = undefined;
277                    V_CoopDig.V_ProductosCueOriList = undefined;
278                    V_CoopDig.V_ProductosCueDesList = undefined;
279                    
280                    Loadfuncion.logeoexitoso();
281					$rootScope.sttError = undefined;
282                    $rootScope.msgError = undefined;
283                    $location.path('/solicitar-credito');
284                    $rootScope.navegacionMenu = 'Consultas - Depósitos';
285                    
286            	} else if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'SR' ) {
287					
288            		//SR: No tienes un ROL asignado para esta aplicación
289					$rootScope.sttError = undefined;
290                    $rootScope.msgError = undefined;
291            		// vm.clean();
292                    if( dataResponse.mensaje ){
293                        vm.mensajeError = dataResponse.mensaje;
294                    }
295                    Loadfuncion.desbanecer();
296                    $location.path('/login-publico');
297                    
298            	} else if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'NUOD' ) {
299					
300            		//NUOD: No es Usuario Oficina Digital. Se establece que no va a ingresar a Oficina Digital
301					$rootScope.sttError = undefined;
302                    $rootScope.msgError = undefined;
303            		// vm.clean();
304                    vm.mensajeError = dataResponse.mensajeError;
305                    Loadfuncion.desbanecer();
306                    $location.path('/login-publico');
307                    
308            	} else if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'RR' ) {
309					
310            		//RR: Registro Requerido
311                    // store username and token in local storage to keep user logged in between page refreshes
312                    $localStorage.currentUser = { username:dataResponse.usuario.username, token:dataResponse.usuario.token, adClientId:dataResponse.usuario.adClientId, adOrgId:dataResponse.usuario.adOrgId, identificacion:dataResponse.usuario.identificacion, tipoIdentificacion:dataResponse.usuario.tipoIdentificacion, email:dataResponse.usuario.email, nombre:dataResponse.usuario.nombre, nombres:dataResponse.usuario.nombres, apellidos:dataResponse.usuario.apellidos, ultimoAcceso:dataResponse.usuario.ultimoAcceso, userId:dataResponse.usuario.userId, adApplicationId:dataResponse.usuario.adApplicationId };
313                    
314                    // add jwt token to auth header for all requests made by the $http service
315                    $http.defaults.headers.common.Authorization = dataResponse.usuario.token;
316                    $http.defaults.headers.Authorization = dataResponse.usuario.token;
317                    
318    	           	$rootScope.objetoUser = dataResponse.usuario;//datos de login 
319    	           	
320                    $log.debug('public-controller RR $rootScope.objetoUser.defaultRol: ',$rootScope.objetoUser.defaultRol);
321                    Loadfuncion.logeoexitoso();
322					$rootScope.sttError = undefined;
323                    $rootScope.msgError = undefined;
324                    if( dataResponse.mensaje ){
325                        $rootScope.msgRR = dataResponse.mensaje;
326                    }
327                    $location.path('/cambiar-seguridad');
328                    $rootScope.navegacionMenu = 'Seguridad - Cambiar opciones de seguridad';
329                    
330            	} else if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'PS' ) {
331            		//PS: Se redirecciona para realizar preguntas de seguridad
332                	vm.display = 3;
333    	           	vm.currentUser = dataResponse.usuario;//datos de login
334    	           	
335    	           	//add jwt token to auth header for all requests made by the $http service
336    	           	$http.defaults.headers.common.Authorization = dataResponse.usuario.token;
337                    $http.defaults.headers.Authorization = dataResponse.usuario.token;
338    	           	
339    	           	$log.debug('public-controller PS vm.currentUser: ',vm.currentUser);
340    	           	if( vm.currentUser && (!vm.currentUser.questionsDTO || !vm.currentUser.questionsDTO.question1 || !vm.currentUser.questionsDTO.question2)){
341    	           		vm.display = 4;
342    	           		vm.mensajeError = 'No se encontró configuración de preguntas de seguridad. Contacta al administrador.';
343    	           	}
344                    
345            	} else if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'TYC' ) {
346            		
347            		// store username and token in local storage to keep user logged in between page refreshes
348                    $localStorage.currentUser = { username:dataResponse.usuario.username, token:dataResponse.usuario.token, adClientId:dataResponse.usuario.adClientId, adOrgId:dataResponse.usuario.adOrgId, identificacion:dataResponse.usuario.identificacion, tipoIdentificacion:dataResponse.usuario.tipoIdentificacion, email:dataResponse.usuario.email, nombre:dataResponse.usuario.nombre, nombres:dataResponse.usuario.nombres, apellidos:dataResponse.usuario.apellidos, ultimoAcceso:dataResponse.usuario.ultimoAcceso, userId:dataResponse.usuario.userId, adApplicationId:dataResponse.usuario.adApplicationId, terminosCondiciones:dataResponse.usuario.terminosCondiciones };
349                    
350            		//TYC: Terminos y condiciones
351    	           	$rootScope.objetoUser = dataResponse.usuario;//datos de login
352    	           	
353                    // add jwt token to auth header for all requests made by the $http service
354                    $http.defaults.headers.common.Authorization = dataResponse.usuario.token;
355                    $http.defaults.headers.Authorization = dataResponse.usuario.token;
356                    
357                    Loadfuncion.logeoexitoso();
358					$rootScope.sttError = undefined;
359                    $rootScope.msgError = undefined;
360                    
361            		$location.path('/t&c');
362                    
363            	}  else if (dataResponse && dataResponse.resultado && dataResponse.resultado == 'CC' ) {
364            		
365            		//CC: Cambio de Clave
366    	           	$rootScope.objetoUser = dataResponse.usuario;//datos de login
367    	           	
368                    // add jwt token to auth header for all requests made by the $http service
369                    $http.defaults.headers.common.Authorization = dataResponse.usuario.token;
370                    $http.defaults.headers.Authorization = dataResponse.usuario.token;
371                    
372            		$location.path('/changePassword');
373            		$rootScope.navegacionMenu = 'Seguridad - Cambiar clave';
374                    
375            	} else {
376            		
377            		// vm.clean();
378                    $location.path('/login-publico');
379                    vm.mensajeError = $rootScope.msgError;
380                    $log.debug('public-controller Login requestCompleted vm.mensajeError{} ', vm.mensajeError);
381					if( dataResponse.data && Object.prototype.toString.call(dataResponse.data) === '[object Array]' ) { vm.validacionesList = dataResponse.data; }
382					else if( dataResponse.data && typeof dataResponse.data === 'string' ) { vm.mensajeError = dataResponse.data; }
383					else if( dataResponse && typeof dataResponse === 'string' ) { vm.mensajeError = dataResponse; }
384            		
385            	}
386                Loadfuncion.desbanecer();
387			} */
388            
389        };
390        
391	}
392	/*--------------------Final  Controlador LoginPublico --------------*/
393	
394})();
395

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.