Ver Fonte

Validacion para proyecciones en instrumentos nuevos, ajuste para mostrar el mensaje correcto en login fallido

Oscar José Nuñez Chávez há 5 anos atrás
pai
commit
a7f6837e63

+ 3 - 2
src/app/components/instruments/cete/cete.component.ts

@@ -107,8 +107,9 @@ export class CETE implements InstrumentComponent {
     this.general = this.formDataService.getGeneralInfo();
 
     if (
-      this.instrument_work.proyecciones != "" ||
-      this.instrument_work != undefined
+      this.instrument_work != undefined &&
+      (this.instrument_work.proyecciones != "" ||
+        this.instrument_work != undefined)
     ) {
       this.hasProjections = true;
       this.dataSource2.data = this.instrument_work.proyecciones;

+ 3 - 2
src/app/components/instruments/dap/dap.component.ts

@@ -105,8 +105,9 @@ export class DAP implements InstrumentComponent {
     this.general = this.formDataService.getGeneralInfo();
 
     if (
-      this.instrument_work.proyecciones != "" ||
-      this.instrument_work != undefined
+      this.instrument_work != undefined &&
+      (this.instrument_work.proyecciones != "" ||
+        this.instrument_work != undefined)
     ) {
       this.hasProjections = true;
       this.dataSource2.data = this.instrument_work.proyecciones;

+ 5 - 1
src/app/components/instruments/pbur/pbur.component.ts

@@ -106,7 +106,11 @@ export class PBUR implements InstrumentComponent {
     this.instrument_exists = this.instrument_work == undefined;
     this.general = this.formDataService.getGeneralInfo();
 
-    if (this.instrument_work.valor_par == true) {
+    if (
+      this.instrument_work != undefined &&
+      this.instrument_work.valor_par == true &&
+      this.instrument_work.proyecciones != undefined
+    ) {
       this.hasProjections = true;
       this.dataSource2.data = this.instrument_work.proyecciones;
       this.dataSource2.paginator = this.paginator;

+ 5 - 1
src/app/components/instruments/vcn/vcn.component.ts

@@ -107,7 +107,11 @@ export class VCN implements InstrumentComponent {
     this.instrument_exists = this.instrument_work == undefined;
     this.general = this.formDataService.getGeneralInfo();
 
-    if (this.instrument_work.valor_par == true) {
+    if (
+      this.instrument_work != undefined &&
+      this.instrument_work.valor_par == true &&
+      this.instrument_work.proyecciones != undefined
+    ) {
       this.hasProjections = true;
       this.dataSource2.data = this.instrument_work.proyecciones;
       this.dataSource2.paginator = this.paginator;

+ 3 - 2
src/app/components/login/login.component.ts

@@ -58,15 +58,16 @@ export class LoginComponent implements OnInit {
             Swal.fire({
               icon: "warning",
               title: "No se pudo auntenticar",
-              text: "Email o contraseña incorrecta"
+              text: "Usuario o contraseña inválidos"
             });
           }
         },
         err => {
+          console.log(err);
           Swal.fire({
             icon: "error",
             title: "Error al autenticar",
-            text: err.message
+            text: "Usuario o contraseña inválidos"
           });
         }
       );

+ 5 - 9
src/app/services/token.interceptor.ts

@@ -26,12 +26,11 @@ export class TokenInterceptor implements HttpInterceptor {
   ): Observable<HttpEvent<any>> {
     if (request.url.indexOf("token/refresh/") != -1) {
       request = this.addToken(request, this.authService.getRefreshToken());
-    }
-    //else if (request.url.indexOf("openweather")!= -1 ){
-    //  request;
-    //}
-    else {
+    } else if (request.url.indexOf("token/") != -1) {
+      request;
+    } else {
       if (this.authService.getJwtToken()) {
+        console.log("THIS2");
         request = this.addToken(request, this.authService.getJwtToken());
       }
     }
@@ -56,10 +55,7 @@ export class TokenInterceptor implements HttpInterceptor {
           }, 2000);
         }
 
-        if (
-          error instanceof HttpErrorResponse &&
-          (error.status === 401 || error.status === 422)
-        ) {
+        if (error instanceof HttpErrorResponse && error.status === 422) {
           return this.handle4xxError(request, next);
         } else {
           return throwError(error);

+ 1 - 1
src/environments/environment.prod.ts

@@ -1,4 +1,4 @@
 export const environment = {
   production: true,
-  productionApiUrl: 'http://192.168.98.140:8000/api'
+  productionApiUrl: "http://192.168.98.146:8000/api"
 };