ngx-sp-auth 3.2.7 → 3.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -759,6 +759,34 @@ class ProjectUtilservice {
759
759
  }
760
760
  }
761
761
  }
762
+ // Exibe a mensagem de erro de uma requisição HTTP em caso de lógica integrada OS
763
+ showHTTPErrorOS(error) {
764
+ if (error.error instanceof ErrorEvent) {
765
+ // Erro ocorreu no lado do cliente
766
+ this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
767
+ }
768
+ else {
769
+ // Erro ocorreu no lado do servidor
770
+ let isUnauthorizedAccess = error.status === 401;
771
+ if (isUnauthorizedAccess) {
772
+ let isFromAplic = this.checkUrlAndMethodService.needsAuthRequest(error.url, "*", this._customEnvironmentService.needsAuthAplic);
773
+ if (isFromAplic) {
774
+ // Remove a autenticação do usuário.
775
+ this.authStorageService.isLoggedInSub.next(false);
776
+ this.authStorageService.urlRedirect = "/";
777
+ this.router.navigate(["/auth/login"]).then(e => {
778
+ this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
779
+ });
780
+ }
781
+ else {
782
+ this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
783
+ }
784
+ }
785
+ else {
786
+ this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
787
+ }
788
+ }
789
+ }
762
790
  // Mostra uma mensagem de sessão expirada.
763
791
  showExpiredAccess(navigationResult) {
764
792
  if (navigationResult) {
@@ -2115,6 +2143,7 @@ class LoginOSComponent {
2115
2143
  const currUsuario = this._storageService.user ?? undefined;
2116
2144
  this._authService.getAuthentication(this._loginOSModel.dominio).subscribe({
2117
2145
  next: () => {
2146
+ throw new Error("Erro de teste");
2118
2147
  if (currDominio === this._loginOSModel.dominio && currUsuario === this._loginOSModel.usuario) {
2119
2148
  status = "keep";
2120
2149
  this.redirect();
@@ -2134,13 +2163,13 @@ class LoginOSComponent {
2134
2163
  },
2135
2164
  error: (error) => {
2136
2165
  this.loginStatus = "error";
2137
- this._projectUtilService.showHttpError(error);
2166
+ this._projectUtilService.showHTTPErrorOS(error);
2138
2167
  },
2139
2168
  });
2140
2169
  },
2141
2170
  error: (error) => {
2142
2171
  this.loginStatus = "error";
2143
- this._projectUtilService.showHttpError(error);
2172
+ this._projectUtilService.showHTTPErrorOS(error);
2144
2173
  }
2145
2174
  });
2146
2175
  }
@@ -2167,8 +2196,10 @@ class LoginOSComponent {
2167
2196
  getParams() {
2168
2197
  const payloadString = this._route.snapshot.queryParamMap.get('payload');
2169
2198
  if (!payloadString) {
2170
- this._messageService.showAlertDanger('Payload não encontrado na URL.');
2171
2199
  this.loginStatus = "error";
2200
+ this._router.navigate(["/auth/login"]).then(e => {
2201
+ this._messageService.showAlertDanger('Payload não encontrado na URL.');
2202
+ });
2172
2203
  console.warn('Payload não encontrado na URL.');
2173
2204
  throw new Error('Payload não encontrado na URL.');
2174
2205
  }
@@ -2187,8 +2218,10 @@ class LoginOSComponent {
2187
2218
  };
2188
2219
  }
2189
2220
  catch (error) {
2190
- this._messageService.showAlertDanger('Erro ao fazer parse do payload.');
2191
2221
  this.loginStatus = "error";
2222
+ this._router.navigate(["/auth/login"]).then(e => {
2223
+ this._messageService.showAlertDanger('Erro ao fazer parse do payload.');
2224
+ });
2192
2225
  console.error('Erro ao fazer parse do payload:', error);
2193
2226
  throw error;
2194
2227
  }