ngx-sp-auth 4.22.5 → 4.22.7
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.
- package/fesm2022/ngx-sp-auth.mjs +328 -210
- package/fesm2022/ngx-sp-auth.mjs.map +1 -1
- package/lib/auth.service.d.ts +2 -3
- package/lib/components/menu-lateral/menu-services.service.d.ts +2 -0
- package/lib/interceptors/auth-aplic.interceptor.d.ts +6 -8
- package/lib/interceptors/auth-infra.interceptor.d.ts +3 -5
- package/lib/services/pesquisa-telas-global.service.d.ts +4 -4
- package/lib/storage/auth-storage.service.d.ts +13 -2
- package/lib/utils/auth-utils.service.d.ts +5 -5
- package/lib/widgets/sub-menu-card/sub-menu-card.component.d.ts +6 -3
- package/package.json +1 -1
package/fesm2022/ngx-sp-auth.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { importProvidersFrom, NgModule, InjectionToken, Inject, Injectable, Component, EventEmitter, Output, Input, TemplateRef, ContentChild,
|
|
2
|
+
import { importProvidersFrom, NgModule, InjectionToken, Inject, Injectable, ViewContainerRef, ViewChild, Component, EventEmitter, Output, Input, TemplateRef, ContentChild, inject } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common/http';
|
|
4
|
-
import { HTTP_INTERCEPTORS,
|
|
4
|
+
import { HTTP_INTERCEPTORS, HttpHeaders, HttpClient, HttpParams, HttpResponse } from '@angular/common/http';
|
|
5
5
|
import * as i1$2 from '@azure/msal-angular';
|
|
6
6
|
import { MsalInterceptor, MsalGuard, MsalModule, MSAL_GUARD_CONFIG } from '@azure/msal-angular';
|
|
7
7
|
import { LogLevel, PublicClientApplication, InteractionType } from '@azure/msal-browser';
|
|
8
8
|
import { take as take$1, tap as tap$1, map, switchMap as switchMap$1 } from 'rxjs/operators';
|
|
9
9
|
import * as i1$1 from '@angular/router';
|
|
10
10
|
import { RouterLink, NavigationEnd, RouterOutlet } from '@angular/router';
|
|
11
|
-
import { BehaviorSubject, take, tap, Subject,
|
|
11
|
+
import { BehaviorSubject, firstValueFrom, take, tap, Subject, Subscription, debounceTime, distinctUntilChanged, filter, switchMap, timer, map as map$1, of, lastValueFrom, from, catchError, throwError } from 'rxjs';
|
|
12
12
|
import * as i3 from 'ngx-sp-infra';
|
|
13
13
|
import { Utils, SearchInputComponent, InfraModule, FormUtils, Usuario, RetPasswordPolicy, RetCheckPassword, CheckPasswordRecord, PasswordPolicyComponent, LibIconsComponent, ContentContainerComponent } from 'ngx-sp-infra';
|
|
14
14
|
import { openDB, deleteDB } from 'idb';
|
|
@@ -512,13 +512,85 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
512
512
|
}]
|
|
513
513
|
}], ctorParameters: () => [{ type: LibCustomEnvironmentService }] });
|
|
514
514
|
|
|
515
|
+
class LibCustomLoginService {
|
|
516
|
+
constructor(_customLoginService) {
|
|
517
|
+
this._customLoginService = _customLoginService;
|
|
518
|
+
}
|
|
519
|
+
// #region Propriedade Customizadas para o Componente login.component.ts
|
|
520
|
+
get loginTitle() {
|
|
521
|
+
return this._customLoginService.loginTitle;
|
|
522
|
+
}
|
|
523
|
+
get loginSubtitle() {
|
|
524
|
+
return this._customLoginService.loginSubtitle;
|
|
525
|
+
}
|
|
526
|
+
get loginBackground() {
|
|
527
|
+
return this._customLoginService.loginBackground;
|
|
528
|
+
}
|
|
529
|
+
get loginLogotipo() {
|
|
530
|
+
return this._customLoginService.loginLogotipo;
|
|
531
|
+
}
|
|
532
|
+
get loginAltLogotipo() {
|
|
533
|
+
return this._customLoginService.loginAltLogotipo;
|
|
534
|
+
}
|
|
535
|
+
get loginPageTitle() {
|
|
536
|
+
return this._customLoginService.loginPageTitle;
|
|
537
|
+
}
|
|
538
|
+
get loginDesenvDomain() {
|
|
539
|
+
return this._customLoginService.loginDesenvDomain;
|
|
540
|
+
}
|
|
541
|
+
get loginDesenvUser() {
|
|
542
|
+
return this._customLoginService.loginDesenvUser;
|
|
543
|
+
}
|
|
544
|
+
get loginDesenvPassword() {
|
|
545
|
+
return this._customLoginService.loginDesenvPassword;
|
|
546
|
+
}
|
|
547
|
+
// #endregion Propriedade Customizadas para o Componente login.component.ts
|
|
548
|
+
// #region Métodos Customizadas para o Componente auth.service.ts
|
|
549
|
+
/**
|
|
550
|
+
* Método executado no auth.service.ts - método: login ()
|
|
551
|
+
* Utilizado para inicializações diversas
|
|
552
|
+
*/
|
|
553
|
+
authLogin() {
|
|
554
|
+
this._customLoginService.authLogin();
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* Método executado no auth.service.ts - método: logout ()
|
|
558
|
+
* Utilizado para inicializações diversas
|
|
559
|
+
*/
|
|
560
|
+
authLogout() {
|
|
561
|
+
this._customLoginService.authLogout();
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Método executado no auth.service.ts - método: login ()
|
|
565
|
+
* Utilizado para informar o redirecionamento para a tela inicial após o login ok
|
|
566
|
+
*
|
|
567
|
+
* @param router Objeto de Router que será utilizado
|
|
568
|
+
*/
|
|
569
|
+
authNavigateToPage(router) {
|
|
570
|
+
this._customLoginService.authNavigateToPage(router);
|
|
571
|
+
}
|
|
572
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibCustomLoginService, deps: [{ token: LIB_CUSTOM_LOGIN_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
573
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibCustomLoginService, providedIn: 'root' }); }
|
|
574
|
+
}
|
|
575
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibCustomLoginService, decorators: [{
|
|
576
|
+
type: Injectable,
|
|
577
|
+
args: [{ providedIn: 'root' }]
|
|
578
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
579
|
+
type: Inject,
|
|
580
|
+
args: [LIB_CUSTOM_LOGIN_SERVICE]
|
|
581
|
+
}] }] });
|
|
582
|
+
|
|
515
583
|
class AuthStorageService {
|
|
516
|
-
constructor(_httpBackend, _customStorageService, _indexedDBService, _customEnvironmentService) {
|
|
584
|
+
constructor(_httpBackend, _customStorageService, _indexedDBService, _customEnvironmentService, _customLoginService, _router) {
|
|
517
585
|
this._httpBackend = _httpBackend;
|
|
518
586
|
this._customStorageService = _customStorageService;
|
|
519
587
|
this._indexedDBService = _indexedDBService;
|
|
520
588
|
this._customEnvironmentService = _customEnvironmentService;
|
|
521
|
-
this.
|
|
589
|
+
this._customLoginService = _customLoginService;
|
|
590
|
+
this._router = _router;
|
|
591
|
+
this._BASE_URL = ''; // SpInfra2LoginWS
|
|
592
|
+
this._LOGOUT_BASE_URL = ''; // SpInfra2LoginWS
|
|
593
|
+
this._HTTP_HEADERS = new HttpHeaders().set('Content-Type', 'application/json');
|
|
522
594
|
this.__local_key = 'user_auth_v6';
|
|
523
595
|
// indica se objeto já está marcado para salvar os dados no local storage.
|
|
524
596
|
this.__isSaving = false;
|
|
@@ -565,8 +637,10 @@ class AuthStorageService {
|
|
|
565
637
|
// azureClientId
|
|
566
638
|
this.__azureClientId = "";
|
|
567
639
|
this._httpClient = new HttpClient(_httpBackend);
|
|
568
|
-
this._BASE_URL = `${_customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`; //
|
|
569
|
-
this._BASE_URL = !_customEnvironmentService.production ? this._BASE_URL : `${_customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`;
|
|
640
|
+
this._BASE_URL = `${_customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`; // SpInfra2LoginWS
|
|
641
|
+
this._BASE_URL = !_customEnvironmentService.production ? this._BASE_URL : `${_customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`; // SpInfra2LoginWS
|
|
642
|
+
this._LOGOUT_BASE_URL = `${_customEnvironmentService.SpInfra2LoginWS}/LogoutSisproErp`; // SpInfra2LoginWS
|
|
643
|
+
this._BASE_URL = !_customEnvironmentService.production ? this._BASE_URL : `${_customEnvironmentService.SpInfra2LoginWS}/LogoutSisproErp`; // SpInfra2LoginWS
|
|
570
644
|
// Método com customizações para inicializações da storage
|
|
571
645
|
this._customStorageService.storageConstructor();
|
|
572
646
|
const expectedLocalAuthStorage = localStorage.getItem(this.__local_key);
|
|
@@ -839,36 +913,33 @@ class AuthStorageService {
|
|
|
839
913
|
// Chama a si próprio depois de um tempo igual ao tempo restante para o vencimento do token, para renovar o token ou deslogar o usuário.
|
|
840
914
|
setTimeout(this.reCheckLogin.bind(this, true), leftTime * 1000);
|
|
841
915
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
this.
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
.catch((err) => console.warn('logout() => falha ao limpar conexão', err));
|
|
870
|
-
// Método com customizações para finalizações da storage
|
|
871
|
-
this._customStorageService.storageLogout();
|
|
916
|
+
/**
|
|
917
|
+
* Realiza o logout do sistema, consumindo o endpoint de logout para remover os cookies e limpando as informações de autenticação armazenadas no localStorage.
|
|
918
|
+
* @returns Promise<boolean> indicando navegação para a tela de login após o logout.
|
|
919
|
+
*/
|
|
920
|
+
async logout() {
|
|
921
|
+
// Consumo de endpoint de logout
|
|
922
|
+
const url = `${this._LOGOUT_BASE_URL}`;
|
|
923
|
+
console.log('1. URL:', url);
|
|
924
|
+
await firstValueFrom(this._httpClient.post(url, null, { 'headers': this._HTTP_HEADERS, withCredentials: true })).then((res) => {
|
|
925
|
+
console.log('2. res:', res);
|
|
926
|
+
})
|
|
927
|
+
.catch((err) => {
|
|
928
|
+
console.log('2.1. teste se aparece aqui no erro do endpoint de logout:', err);
|
|
929
|
+
})
|
|
930
|
+
.then(() => {
|
|
931
|
+
// Independente de sucesso ou erro, realiza a limpeza do localStorage após o endpoint ser chamado
|
|
932
|
+
console.log('3. Removendo variáveis de configuração do usuário e senha do localStorage');
|
|
933
|
+
localStorage.removeItem('configServerUser');
|
|
934
|
+
localStorage.removeItem('configServerPassword');
|
|
935
|
+
console.log('4. Chamando método onLogout() para limpar variáveis de autenticação e redirecionar para a tela de login');
|
|
936
|
+
this.onLogout();
|
|
937
|
+
// Método com customizações para inicializações do Logout
|
|
938
|
+
console.log('5. Chamando método authLogout() do serviço de customização para realizar ações de logout específicas');
|
|
939
|
+
this._customLoginService.authLogout();
|
|
940
|
+
});
|
|
941
|
+
console.log('6. Navegando para rota de login');
|
|
942
|
+
return this._router.navigate(["/auth/login"]);
|
|
872
943
|
}
|
|
873
944
|
getNewTokenBack() {
|
|
874
945
|
let token = {
|
|
@@ -881,15 +952,14 @@ class AuthStorageService {
|
|
|
881
952
|
};
|
|
882
953
|
const url = `${this._BASE_URL}/GetNewToken`;
|
|
883
954
|
const headers = new HttpHeaders()
|
|
884
|
-
.set('Content-Type', 'application/json')
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
}));
|
|
955
|
+
.set('Content-Type', 'application/json');
|
|
956
|
+
// Remover/comentar o header abaixo pois o token será enviado via Cookie HttpOnly, e não mais via header Authorization
|
|
957
|
+
// .set('Authorization',
|
|
958
|
+
// `Basic ${btoa(`${localStorage.getItem('configServerUser')}:${localStorage.getItem('configServerPassword')}`)}`
|
|
959
|
+
// );
|
|
960
|
+
return this._httpClient.post(url, token, { 'headers': headers, withCredentials: true })
|
|
961
|
+
.pipe(take(1), tap((response) => { if (response.Error)
|
|
962
|
+
throw Error(response.ErrorMessage); }));
|
|
893
963
|
}
|
|
894
964
|
getNewToken() {
|
|
895
965
|
return new Promise((resolve, reject) => {
|
|
@@ -926,6 +996,39 @@ class AuthStorageService {
|
|
|
926
996
|
}
|
|
927
997
|
}
|
|
928
998
|
}
|
|
999
|
+
onLogout() {
|
|
1000
|
+
console.log('4.1. Iniciando onLogout() para limpar variáveis de autenticação e redirecionar para a tela de login');
|
|
1001
|
+
this.__isCheckingAuth = false;
|
|
1002
|
+
this.isLoggedInSub.next(false);
|
|
1003
|
+
this.__UrlRedirect = "/";
|
|
1004
|
+
this.__ip = "";
|
|
1005
|
+
this.__tenantId = 0;
|
|
1006
|
+
this.__infraUsuarioId = "";
|
|
1007
|
+
this.__infraEstabId = "";
|
|
1008
|
+
this.__infraEstabNome = "";
|
|
1009
|
+
this.__infraEmpresaId = "";
|
|
1010
|
+
this.__infraEmpresaNome = "";
|
|
1011
|
+
this.__user = "";
|
|
1012
|
+
this.__userName = "";
|
|
1013
|
+
this.__authToken = "";
|
|
1014
|
+
this.__dominio = "";
|
|
1015
|
+
this.__tokenPayload = {};
|
|
1016
|
+
this.__isExternalLogin = false;
|
|
1017
|
+
this.__infraInAuthTypeId = 0;
|
|
1018
|
+
this.__infraIn2FaTypeId = null;
|
|
1019
|
+
this.__is2FaEnabled = false;
|
|
1020
|
+
this.__azureTenantId = "";
|
|
1021
|
+
this.__azureClientId = "";
|
|
1022
|
+
console.log('4.2. __localKey:', this.__local_key);
|
|
1023
|
+
localStorage.removeItem(this.__local_key);
|
|
1024
|
+
// Limpa o armazenamento local do navegador que contém os filtros de um produto específico
|
|
1025
|
+
// Fecha a conexão local (se houver) antes de excluir a database para evitar o callback 'blocking'
|
|
1026
|
+
this._indexedDBService.closeOpenConnection()
|
|
1027
|
+
.then(() => this._indexedDBService.deleteDatabase())
|
|
1028
|
+
.catch((err) => console.warn('logout() => falha ao limpar conexão', err));
|
|
1029
|
+
// Método com customizações para finalizações da storage
|
|
1030
|
+
this._customStorageService.storageLogout();
|
|
1031
|
+
}
|
|
929
1032
|
isPrePortal() {
|
|
930
1033
|
// Identifica se a origem é PrePortal
|
|
931
1034
|
var url = new URL(window.location.href);
|
|
@@ -942,114 +1045,46 @@ class AuthStorageService {
|
|
|
942
1045
|
return false;
|
|
943
1046
|
}
|
|
944
1047
|
}
|
|
945
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthStorageService, deps: [{ token: i1.HttpBackend }, { token: LibCustomStorageService }, { token: IndexedDBService }, { token: LibCustomEnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1048
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthStorageService, deps: [{ token: i1.HttpBackend }, { token: LibCustomStorageService }, { token: IndexedDBService }, { token: LibCustomEnvironmentService }, { token: LibCustomLoginService }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
946
1049
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthStorageService, providedIn: 'root' }); }
|
|
947
1050
|
}
|
|
948
1051
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthStorageService, decorators: [{
|
|
949
1052
|
type: Injectable,
|
|
950
1053
|
args: [{ providedIn: 'root' }]
|
|
951
|
-
}], ctorParameters: () => [{ type: i1.HttpBackend }, { type: LibCustomStorageService }, { type: IndexedDBService }, { type: LibCustomEnvironmentService }] });
|
|
952
|
-
|
|
953
|
-
class LibCustomLoginService {
|
|
954
|
-
constructor(_customLoginService) {
|
|
955
|
-
this._customLoginService = _customLoginService;
|
|
956
|
-
}
|
|
957
|
-
// #region Propriedade Customizadas para o Componente login.component.ts
|
|
958
|
-
get loginTitle() {
|
|
959
|
-
return this._customLoginService.loginTitle;
|
|
960
|
-
}
|
|
961
|
-
get loginSubtitle() {
|
|
962
|
-
return this._customLoginService.loginSubtitle;
|
|
963
|
-
}
|
|
964
|
-
get loginBackground() {
|
|
965
|
-
return this._customLoginService.loginBackground;
|
|
966
|
-
}
|
|
967
|
-
get loginLogotipo() {
|
|
968
|
-
return this._customLoginService.loginLogotipo;
|
|
969
|
-
}
|
|
970
|
-
get loginAltLogotipo() {
|
|
971
|
-
return this._customLoginService.loginAltLogotipo;
|
|
972
|
-
}
|
|
973
|
-
get loginPageTitle() {
|
|
974
|
-
return this._customLoginService.loginPageTitle;
|
|
975
|
-
}
|
|
976
|
-
get loginDesenvDomain() {
|
|
977
|
-
return this._customLoginService.loginDesenvDomain;
|
|
978
|
-
}
|
|
979
|
-
get loginDesenvUser() {
|
|
980
|
-
return this._customLoginService.loginDesenvUser;
|
|
981
|
-
}
|
|
982
|
-
get loginDesenvPassword() {
|
|
983
|
-
return this._customLoginService.loginDesenvPassword;
|
|
984
|
-
}
|
|
985
|
-
// #endregion Propriedade Customizadas para o Componente login.component.ts
|
|
986
|
-
// #region Métodos Customizadas para o Componente auth.service.ts
|
|
987
|
-
/**
|
|
988
|
-
* Método executado no auth.service.ts - método: login ()
|
|
989
|
-
* Utilizado para inicializações diversas
|
|
990
|
-
*/
|
|
991
|
-
authLogin() {
|
|
992
|
-
this._customLoginService.authLogin();
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* Método executado no auth.service.ts - método: logout ()
|
|
996
|
-
* Utilizado para inicializações diversas
|
|
997
|
-
*/
|
|
998
|
-
authLogout() {
|
|
999
|
-
this._customLoginService.authLogout();
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Método executado no auth.service.ts - método: login ()
|
|
1003
|
-
* Utilizado para informar o redirecionamento para a tela inicial após o login ok
|
|
1004
|
-
*
|
|
1005
|
-
* @param router Objeto de Router que será utilizado
|
|
1006
|
-
*/
|
|
1007
|
-
authNavigateToPage(router) {
|
|
1008
|
-
this._customLoginService.authNavigateToPage(router);
|
|
1009
|
-
}
|
|
1010
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibCustomLoginService, deps: [{ token: LIB_CUSTOM_LOGIN_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1011
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibCustomLoginService, providedIn: 'root' }); }
|
|
1012
|
-
}
|
|
1013
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LibCustomLoginService, decorators: [{
|
|
1014
|
-
type: Injectable,
|
|
1015
|
-
args: [{ providedIn: 'root' }]
|
|
1016
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1017
|
-
type: Inject,
|
|
1018
|
-
args: [LIB_CUSTOM_LOGIN_SERVICE]
|
|
1019
|
-
}] }] });
|
|
1054
|
+
}], ctorParameters: () => [{ type: i1.HttpBackend }, { type: LibCustomStorageService }, { type: IndexedDBService }, { type: LibCustomEnvironmentService }, { type: LibCustomLoginService }, { type: i1$1.Router }] });
|
|
1020
1055
|
|
|
1021
1056
|
class AuthUtilService {
|
|
1022
|
-
constructor(
|
|
1023
|
-
this.
|
|
1024
|
-
this.
|
|
1025
|
-
this.checkUrlAndMethodService = checkUrlAndMethodService;
|
|
1026
|
-
this.messageService = messageService;
|
|
1057
|
+
constructor(_authStorageService, _checkUrlAndMethodService, _customEnvironmentService, _message, _router) {
|
|
1058
|
+
this._authStorageService = _authStorageService;
|
|
1059
|
+
this._checkUrlAndMethodService = _checkUrlAndMethodService;
|
|
1027
1060
|
this._customEnvironmentService = _customEnvironmentService;
|
|
1061
|
+
this._message = _message;
|
|
1062
|
+
this._router = _router;
|
|
1028
1063
|
}
|
|
1029
1064
|
// Exibe a mensagem de erro de uma requisição http
|
|
1030
1065
|
showHttpError(error) {
|
|
1031
1066
|
if (error.error instanceof ErrorEvent) {
|
|
1032
1067
|
// Erro ocorreu no lado do cliente
|
|
1033
|
-
this.
|
|
1068
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1034
1069
|
}
|
|
1035
1070
|
else {
|
|
1036
1071
|
// Erro ocorreu no lado do servidor
|
|
1037
1072
|
let isUnauthorizedAccess = error.status === 401;
|
|
1038
1073
|
if (isUnauthorizedAccess) {
|
|
1039
|
-
let isFromAplic = this.
|
|
1074
|
+
let isFromAplic = this._checkUrlAndMethodService.needsAuthRequest(error.url, "*", this._customEnvironmentService.needsAuthAplic);
|
|
1040
1075
|
if (isFromAplic) {
|
|
1076
|
+
// Comentado pois neste projeto esta alteração de valores não realizava o logout como deveria corretamente...
|
|
1077
|
+
// this.authStorageService.isLoggedInSub.next(false);
|
|
1078
|
+
// this.authStorageService.urlRedirect = "/";
|
|
1041
1079
|
// Remove a autenticação do usuário.
|
|
1042
|
-
this.
|
|
1043
|
-
this.authStorageService.urlRedirect = "/";
|
|
1044
|
-
let promise = this.router.navigate(["/auth/login"]);
|
|
1045
|
-
promise.then(this.showExpiredAccess.bind(this));
|
|
1080
|
+
this._authStorageService.logout().then(this.showExpiredAccess.bind(this));
|
|
1046
1081
|
}
|
|
1047
1082
|
else {
|
|
1048
|
-
this.
|
|
1083
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1049
1084
|
}
|
|
1050
1085
|
}
|
|
1051
1086
|
else {
|
|
1052
|
-
this.
|
|
1087
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1053
1088
|
}
|
|
1054
1089
|
}
|
|
1055
1090
|
}
|
|
@@ -1057,32 +1092,33 @@ class AuthUtilService {
|
|
|
1057
1092
|
showHTTPErrorOS(error) {
|
|
1058
1093
|
if (error.error instanceof ErrorEvent) {
|
|
1059
1094
|
// Erro ocorreu no lado do cliente
|
|
1060
|
-
this.
|
|
1061
|
-
this.
|
|
1095
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
1096
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1062
1097
|
});
|
|
1063
1098
|
}
|
|
1064
1099
|
else {
|
|
1065
1100
|
// Erro ocorreu no lado do servidor
|
|
1066
1101
|
let isUnauthorizedAccess = error.status === 401;
|
|
1067
1102
|
if (isUnauthorizedAccess) {
|
|
1068
|
-
let isFromAplic = this.
|
|
1103
|
+
let isFromAplic = this._checkUrlAndMethodService.needsAuthRequest(error.url, "*", this._customEnvironmentService.needsAuthAplic);
|
|
1069
1104
|
if (isFromAplic) {
|
|
1105
|
+
// Comentado pois neste projeto esta alteração de valores não realizava o logout como deveria corretamente...
|
|
1106
|
+
// this.authStorageService.isLoggedInSub.next(false);
|
|
1107
|
+
// this.authStorageService.urlRedirect = "/";
|
|
1070
1108
|
// Remove a autenticação do usuário.
|
|
1071
|
-
this.
|
|
1072
|
-
|
|
1073
|
-
this.router.navigate(["/auth/login"]).then(e => {
|
|
1074
|
-
this.messageService.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1109
|
+
this._authStorageService.logout().then(() => {
|
|
1110
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1075
1111
|
});
|
|
1076
1112
|
}
|
|
1077
1113
|
else {
|
|
1078
|
-
this.
|
|
1079
|
-
this.
|
|
1114
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
1115
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1080
1116
|
});
|
|
1081
1117
|
}
|
|
1082
1118
|
}
|
|
1083
1119
|
else {
|
|
1084
|
-
this.
|
|
1085
|
-
this.
|
|
1120
|
+
this._router.navigate(["/auth/login"]).then(e => {
|
|
1121
|
+
this._message.showAlertDanger(Utils.getHttpErrorMessage(error));
|
|
1086
1122
|
});
|
|
1087
1123
|
}
|
|
1088
1124
|
}
|
|
@@ -1090,14 +1126,14 @@ class AuthUtilService {
|
|
|
1090
1126
|
// Mostra uma mensagem de sessão expirada.
|
|
1091
1127
|
showExpiredAccess(navigationResult) {
|
|
1092
1128
|
if (navigationResult) {
|
|
1093
|
-
this.
|
|
1129
|
+
this._message.showAlertWarning("Sessão expirada, logue-se novamente.");
|
|
1094
1130
|
}
|
|
1095
1131
|
}
|
|
1096
1132
|
// Obtém o hostName
|
|
1097
1133
|
getHostName() {
|
|
1098
1134
|
return this._customEnvironmentService.hostName;
|
|
1099
1135
|
}
|
|
1100
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthUtilService, deps: [{ token:
|
|
1136
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthUtilService, deps: [{ token: AuthStorageService }, { token: i3.CheckUrlAndMethodService }, { token: LibCustomEnvironmentService }, { token: i3.MessageService }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1101
1137
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthUtilService, providedIn: 'root' }); }
|
|
1102
1138
|
}
|
|
1103
1139
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthUtilService, decorators: [{
|
|
@@ -1105,7 +1141,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
1105
1141
|
args: [{
|
|
1106
1142
|
providedIn: 'root'
|
|
1107
1143
|
}]
|
|
1108
|
-
}], ctorParameters: () => [{ type:
|
|
1144
|
+
}], ctorParameters: () => [{ type: AuthStorageService }, { type: i3.CheckUrlAndMethodService }, { type: LibCustomEnvironmentService }, { type: i3.MessageService }, { type: i1$1.Router }] });
|
|
1109
1145
|
|
|
1110
1146
|
class AuthService {
|
|
1111
1147
|
// #endregion PRIVATE
|
|
@@ -1122,20 +1158,23 @@ class AuthService {
|
|
|
1122
1158
|
// #region ==========> PROPERTIES <==========
|
|
1123
1159
|
// #region PRIVATE
|
|
1124
1160
|
this._pendingWarning = null;
|
|
1125
|
-
this._BASE_URL = ''; // SpInfra2WS
|
|
1126
1161
|
this._AUTH_BASE_URL = ''; // SpInfra2AuthWS
|
|
1162
|
+
this._BASE_URL = ''; // SpInfra2WS
|
|
1127
1163
|
this._BASE_OS_URL = ''; // SpInfra2LoginWS
|
|
1164
|
+
this._LOGOUT_BASE_URL = ''; // SpInfra2LoginWS
|
|
1128
1165
|
this._HTTP_HEADERS = new HttpHeaders().set('Content-Type', 'application/json');
|
|
1129
1166
|
this.ip = "undefined";
|
|
1130
1167
|
this.city = "undefined";
|
|
1131
1168
|
this.state = "undefined";
|
|
1132
1169
|
this.country = "undefined";
|
|
1133
|
-
this._BASE_URL = `${this._customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`; // SpInfra2WS
|
|
1134
1170
|
this._AUTH_BASE_URL = `${this._customEnvironmentService.SpInfra2AuthWS}/Auth`; // SpInfra2AuthWS
|
|
1171
|
+
this._BASE_URL = `${this._customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`; // SpInfra2LoginWS
|
|
1135
1172
|
this._BASE_OS_URL = `${this._customEnvironmentService.SpInfra2LoginWS}/LoginIntegradoOS`; // SpInfra2LoginWS
|
|
1136
|
-
this.
|
|
1173
|
+
this._LOGOUT_BASE_URL = `${this._customEnvironmentService.SpInfra2LoginWS}/LogoutSisproErp`; // SpInfra2LoginWS
|
|
1137
1174
|
this._AUTH_BASE_URL = !this._customEnvironmentService.production ? this._AUTH_BASE_URL : `${this._customEnvironmentService.SpInfra2AuthWS}/Auth`;
|
|
1175
|
+
this._BASE_URL = !this._customEnvironmentService.production ? this._BASE_URL : `${this._customEnvironmentService.SpInfra2LoginWS}/LoginSisproERP`;
|
|
1138
1176
|
this._BASE_OS_URL = !this._customEnvironmentService.production ? this._BASE_OS_URL : `${this._customEnvironmentService.SpInfra2LoginWS}/LoginIntegradoOS`;
|
|
1177
|
+
this._LOGOUT_BASE_URL = !this._customEnvironmentService.production ? this._LOGOUT_BASE_URL : `${this._customEnvironmentService.SpInfra2LoginWS}/LogoutSisproErp`;
|
|
1139
1178
|
this.getParms();
|
|
1140
1179
|
}
|
|
1141
1180
|
// #region ==========> SERVICE METHODS <==========
|
|
@@ -1193,8 +1232,10 @@ class AuthService {
|
|
|
1193
1232
|
if (response.Error) {
|
|
1194
1233
|
throw Error(response.ErrorMessage);
|
|
1195
1234
|
}
|
|
1196
|
-
|
|
1197
|
-
|
|
1235
|
+
// Comentadas pois não serão mais armazenadas desta forma, o webservice gerará um Cookie com o valor já formatado para Base64
|
|
1236
|
+
// E o mesmo será enviada nas requisições subsequentes via párâmetro `withCredentials: true`, e não mais via header Authorization
|
|
1237
|
+
// localStorage.setItem('configServerUser', response.User);
|
|
1238
|
+
// localStorage.setItem('configServerPassword', response.Password);
|
|
1198
1239
|
this._authStorageService.tenantId = response.TenantId;
|
|
1199
1240
|
this._authStorageService.dominio = response.Domain;
|
|
1200
1241
|
this._authStorageService.infraInAuthTypeId = response.InfraInAuthTypeId;
|
|
@@ -1438,15 +1479,6 @@ class AuthService {
|
|
|
1438
1479
|
}
|
|
1439
1480
|
}));
|
|
1440
1481
|
}
|
|
1441
|
-
/** Realiza o logout do sistema, removendo tokens do localStorage e limpando cache */
|
|
1442
|
-
logout() {
|
|
1443
|
-
this._authStorageService.logout();
|
|
1444
|
-
localStorage.removeItem('configsServerUser');
|
|
1445
|
-
localStorage.removeItem('configsServerPassword');
|
|
1446
|
-
// Método com customizações para inicializações do Logout
|
|
1447
|
-
this._customLoginService.authLogout();
|
|
1448
|
-
this._router.navigate(["/auth/login"]);
|
|
1449
|
-
}
|
|
1450
1482
|
validateAuthentication2Fa(code) {
|
|
1451
1483
|
let Code2Fa = {
|
|
1452
1484
|
infraUsuarioId: this._authStorageService.infraUsuarioId,
|
|
@@ -1564,6 +1596,7 @@ class AuthService {
|
|
|
1564
1596
|
}
|
|
1565
1597
|
}));
|
|
1566
1598
|
}
|
|
1599
|
+
// TODO: Criar método de logout aqui que usa os métodos de limpeza de storage do `auth-storage.service.ts`...
|
|
1567
1600
|
// #endregion POST
|
|
1568
1601
|
// #endregion ==========> SERVICE METHODS <==========
|
|
1569
1602
|
// #region ==========> UTILS <==========
|
|
@@ -1598,7 +1631,7 @@ class MenuServicesService {
|
|
|
1598
1631
|
// #region NewImg Event
|
|
1599
1632
|
// Implementação de lógica vista no link: https://hasangalakdinu.medium.com/how-to-call-a-function-in-another-component-angular-using-rxjs-3f2e85920705
|
|
1600
1633
|
this._subject = new Subject();
|
|
1601
|
-
this._BASE_URL = `${this._customEnvironmentService.
|
|
1634
|
+
this._BASE_URL = `${this._customEnvironmentService.Sp2LocalhostWS}`; // SpInfra2ErpWS
|
|
1602
1635
|
this._BASE_URL = !this._customEnvironmentService.production ? this._BASE_URL : `${this._customEnvironmentService.SpInfra2ErpWS}`;
|
|
1603
1636
|
this._BASE_URL_VERSION_INFRA = `${this._customEnvironmentService.SpInfra2AuthWS.replace('SpInfra2AuthWS', 'SpInfra2VersionWS')}`; // SpInfra2VersionWS
|
|
1604
1637
|
this._BASE_URL_VERSION_INFRA = !this._customEnvironmentService.production ? this._BASE_URL_VERSION_INFRA : `${this._customEnvironmentService.SpInfra2AuthWS.replace('SpInfra2AuthWS', 'SpInfra2VersionWS')}`;
|
|
@@ -1819,6 +1852,13 @@ class MenuServicesService {
|
|
|
1819
1852
|
}
|
|
1820
1853
|
}));
|
|
1821
1854
|
}
|
|
1855
|
+
/** Método executado para pegar o HostName de direcionamento para a V6. */
|
|
1856
|
+
GetHostServerV6() {
|
|
1857
|
+
const url = `${this._BASE_URL}/Menu/GetHostServerV6`;
|
|
1858
|
+
return this._httpClient.get(url, { headers: this._HTTP_HEADERS })
|
|
1859
|
+
.pipe(take(1), tap((response) => { if (response.Error)
|
|
1860
|
+
throw Error(response.ErrorMessage); }));
|
|
1861
|
+
}
|
|
1822
1862
|
/**
|
|
1823
1863
|
* **ESTE MÉTODO FOI DUPLICADO DO MÉTODO `GetHostServerOutSystems` PARA SER UTILIZADO DE FORMA ASSÍNCRONA, SEM *OBSERVABLE*, PARA EVITAR PROBLEMAS DE SINCRONIA NA CONSTRUÇÃO DO MENU DINÂMICO.**
|
|
1824
1864
|
*
|
|
@@ -1987,16 +2027,12 @@ class PesquisaTelasGlobalService {
|
|
|
1987
2027
|
// #region PUBLIC
|
|
1988
2028
|
// #endregion PUBLIC
|
|
1989
2029
|
// #endregion ==========> PROPERTIES <==========
|
|
1990
|
-
constructor(
|
|
1991
|
-
this._componentFactoryResolver = _componentFactoryResolver;
|
|
2030
|
+
constructor(_appRef, _injector, _httpClient, _customEnvironmentService, _authUtils) {
|
|
1992
2031
|
this._appRef = _appRef;
|
|
1993
2032
|
this._injector = _injector;
|
|
1994
2033
|
this._httpClient = _httpClient;
|
|
1995
2034
|
this._customEnvironmentService = _customEnvironmentService;
|
|
1996
2035
|
this._authUtils = _authUtils;
|
|
1997
|
-
// #region ==========> PROPERTIES <==========
|
|
1998
|
-
// #region PRIVATE
|
|
1999
|
-
// #region GERENCIAMENTO DINÂMICO DO COMPONENTE
|
|
2000
2036
|
/**
|
|
2001
2037
|
* Referência ao componente dinâmico criado.
|
|
2002
2038
|
* Usado para gerenciar o ciclo de vida e estado do componente.
|
|
@@ -2118,7 +2154,7 @@ class PesquisaTelasGlobalService {
|
|
|
2118
2154
|
*
|
|
2119
2155
|
* Este método utiliza a API baixo nível do Angular para criar um componente dinamicamente e anexá-lo ao DOM. O processo envolve:
|
|
2120
2156
|
*
|
|
2121
|
-
* 1. Criar o componente via
|
|
2157
|
+
* 1. Criar o componente via `container.createComponent()`
|
|
2122
2158
|
* 2. Configurar suas propriedades iniciais
|
|
2123
2159
|
* 3. Registrá-lo no mecanismo de detecção de mudanças do Angular
|
|
2124
2160
|
* 4. Anexá-lo ao DOM (fora da hierarquia normal de componentes)
|
|
@@ -2134,24 +2170,18 @@ class PesquisaTelasGlobalService {
|
|
|
2134
2170
|
if (this._componentRef) {
|
|
2135
2171
|
return;
|
|
2136
2172
|
}
|
|
2137
|
-
// 1.
|
|
2138
|
-
|
|
2139
|
-
//
|
|
2140
|
-
const componentFactory = this._componentFactoryResolver.resolveComponentFactory(SearchInputComponent);
|
|
2141
|
-
// 2. Cria uma nova instância do componente usando o injector raiz
|
|
2142
|
-
// Isso garante que o componente tenha acesso aos mesmos serviços
|
|
2143
|
-
// que componentes criados normalmente via template
|
|
2144
|
-
this._componentRef = componentFactory.create(this._injector);
|
|
2145
|
-
// 3. Registra a view do componente no ApplicationRef
|
|
2173
|
+
// 1. Cria uma nova instância do componente
|
|
2174
|
+
this._componentRef = this._container.createComponent(SearchInputComponent);
|
|
2175
|
+
// 2. Registra a view do componente no ApplicationRef
|
|
2146
2176
|
// Isso é CRÍTICO: sem este passo, o componente não participaria
|
|
2147
2177
|
// do ciclo de detecção de mudanças do Angular
|
|
2148
2178
|
this._appRef.attachView(this._componentRef.hostView);
|
|
2149
|
-
//
|
|
2179
|
+
// 3. Obtém o elemento DOM raiz do componente e o anexa ao body
|
|
2150
2180
|
// Como este componente é criado fora da hierarquia normal,
|
|
2151
2181
|
// precisamos anexá-lo manualmente ao DOM
|
|
2152
2182
|
const domElem = this._componentRef.hostView.rootNodes[0];
|
|
2153
2183
|
document.body.appendChild(domElem);
|
|
2154
|
-
//
|
|
2184
|
+
// 4. Configura os listeners dos eventos do componente
|
|
2155
2185
|
// Em vez de tratar o hide() diretamente aqui, encaminhamos o evento para o Subject _onClose$ e guardamos a subscription para poder removê-la quando escondermos o componente.
|
|
2156
2186
|
this._componentCloseSub = this._componentRef.instance.onClose.subscribe(() => this._onClose$.next());
|
|
2157
2187
|
// Em vez de tratar o getTelas() diretamente aqui, encaminhamos o evento para o Subject _onSearch$ e guardamos a subscription para poder removê-la quando escondermos o componente.
|
|
@@ -2195,13 +2225,16 @@ class PesquisaTelasGlobalService {
|
|
|
2195
2225
|
// #endregion GERENCIAMENTO DO COMPONENTE
|
|
2196
2226
|
showErrorMessage(response) { if (response.Error)
|
|
2197
2227
|
throw Error(response.ErrorMessage); }
|
|
2198
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, deps: [{ token: i0.
|
|
2228
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, deps: [{ token: i0.ApplicationRef }, { token: i0.Injector }, { token: i1.HttpClient }, { token: LibCustomEnvironmentService }, { token: AuthUtilService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2199
2229
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, providedIn: 'root' }); }
|
|
2200
2230
|
}
|
|
2201
2231
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: PesquisaTelasGlobalService, decorators: [{
|
|
2202
2232
|
type: Injectable,
|
|
2203
2233
|
args: [{ providedIn: 'root' }]
|
|
2204
|
-
}], ctorParameters: () => [{ type: i0.
|
|
2234
|
+
}], ctorParameters: () => [{ type: i0.ApplicationRef }, { type: i0.Injector }, { type: i1.HttpClient }, { type: LibCustomEnvironmentService }, { type: AuthUtilService }], propDecorators: { _container: [{
|
|
2235
|
+
type: ViewChild,
|
|
2236
|
+
args: ['container', { read: ViewContainerRef, static: true }]
|
|
2237
|
+
}] } });
|
|
2205
2238
|
|
|
2206
2239
|
class ErrorMenuNotAllowed {
|
|
2207
2240
|
constructor(router, authStorageService) {
|
|
@@ -3676,7 +3709,7 @@ class MenuLateralComponent {
|
|
|
3676
3709
|
postLogoutRedirectUri: hostAuthLogin
|
|
3677
3710
|
});
|
|
3678
3711
|
}
|
|
3679
|
-
this.
|
|
3712
|
+
this._authStorageService.logout();
|
|
3680
3713
|
}
|
|
3681
3714
|
getExternalUrl(url, isOutroModulo) {
|
|
3682
3715
|
if (url.includes('https://'))
|
|
@@ -4675,15 +4708,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
4675
4708
|
;
|
|
4676
4709
|
|
|
4677
4710
|
/**
|
|
4678
|
-
*
|
|
4679
|
-
* com o login para uso da API.
|
|
4680
|
-
*
|
|
4711
|
+
* Intercepta uma chamada HTTP para inserir o usuário logado nos cookies (e header, para compatibilidade) em conjunto com o login para uso da API.
|
|
4681
4712
|
* Depende do serviço de autenticação.
|
|
4682
|
-
|
|
4713
|
+
*/
|
|
4683
4714
|
class AuthAplicInterceptor {
|
|
4684
|
-
constructor(
|
|
4685
|
-
this.
|
|
4686
|
-
this.
|
|
4715
|
+
constructor(_authCheckService, _authStorage, _customEnvironmentService) {
|
|
4716
|
+
this._authCheckService = _authCheckService;
|
|
4717
|
+
this._authStorage = _authStorage;
|
|
4687
4718
|
this._customEnvironmentService = _customEnvironmentService;
|
|
4688
4719
|
}
|
|
4689
4720
|
intercept(req, next) {
|
|
@@ -4692,14 +4723,34 @@ class AuthAplicInterceptor {
|
|
|
4692
4723
|
}
|
|
4693
4724
|
async handle(req, next) {
|
|
4694
4725
|
let changedReq = req;
|
|
4695
|
-
if (this.
|
|
4726
|
+
if (this._authCheckService.needsAuthRequest(req.url, req.method, this._customEnvironmentService.needsAuthAplic)) {
|
|
4696
4727
|
// Verifica se o Token precisa ser renovado
|
|
4697
|
-
await this.
|
|
4728
|
+
await this._authStorage.renewToken();
|
|
4698
4729
|
// Adiciona as autenticações necessárias ao servidor.
|
|
4699
|
-
|
|
4700
|
-
|
|
4730
|
+
// Daqui alguns dias este trecho será removido e os tokens serão enviados exclusivamente pelos Cookies, mas por enquanto, para manter compatibilidade com o que já existe, o token será enviado no header
|
|
4731
|
+
// let headers: HttpHeaders = req.headers.set(
|
|
4732
|
+
// 'Authorization',
|
|
4733
|
+
// `Bearer ${this._authStorage.authToken}`
|
|
4734
|
+
// );
|
|
4735
|
+
changedReq = req.clone({
|
|
4736
|
+
// headers: headers,
|
|
4737
|
+
withCredentials: true // Parâmetro necessário para utilização dos Cookies HttpOnly
|
|
4738
|
+
});
|
|
4701
4739
|
}
|
|
4702
|
-
return await lastValueFrom(next.handle(changedReq));
|
|
4740
|
+
// return await lastValueFrom(next.handle(changedReq));
|
|
4741
|
+
// Exemplo de leitura de resposta via interceptor abaixo:
|
|
4742
|
+
return await lastValueFrom(next.handle(changedReq)
|
|
4743
|
+
// INTERCEPTAR RESPOSTA
|
|
4744
|
+
.pipe(tap(event => {
|
|
4745
|
+
if (event instanceof HttpResponse) {
|
|
4746
|
+
// console.log("Resposta HTTP interceptada:", event);
|
|
4747
|
+
}
|
|
4748
|
+
}),
|
|
4749
|
+
// INTERCEPTAR ERRO
|
|
4750
|
+
catchError(error => {
|
|
4751
|
+
// console.error("Erro HTTP interceptado:", error);
|
|
4752
|
+
return throwError(() => error);
|
|
4753
|
+
})));
|
|
4703
4754
|
}
|
|
4704
4755
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthAplicInterceptor, deps: [{ token: i3.CheckUrlAndMethodService }, { token: AuthStorageService }, { token: LibCustomEnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4705
4756
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthAplicInterceptor, providedIn: 'root' }); }
|
|
@@ -4709,23 +4760,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
4709
4760
|
args: [{ providedIn: 'root' }]
|
|
4710
4761
|
}], ctorParameters: () => [{ type: i3.CheckUrlAndMethodService }, { type: AuthStorageService }, { type: LibCustomEnvironmentService }] });
|
|
4711
4762
|
|
|
4712
|
-
/**
|
|
4713
|
-
* \brief Intercepta uma chamada HTTP para inserir a autenticação da Sispro.
|
|
4714
|
-
*/
|
|
4763
|
+
/** Intercepta uma chamada HTTP para inserir a autenticação da básica das APIs nos Cookies (e no header, para compatibilidade) */
|
|
4715
4764
|
class AuthInfraInterceptor {
|
|
4716
|
-
constructor(
|
|
4717
|
-
this.
|
|
4765
|
+
constructor(_authCheckService, _customEnvironmentService) {
|
|
4766
|
+
this._authCheckService = _authCheckService;
|
|
4718
4767
|
this._customEnvironmentService = _customEnvironmentService;
|
|
4719
4768
|
}
|
|
4720
4769
|
intercept(req, next) {
|
|
4721
4770
|
let changedReq = req;
|
|
4722
|
-
if (this.
|
|
4771
|
+
if (this._authCheckService.needsAuthRequest(req.url, req.method, this._customEnvironmentService.needsAuthInfra)) {
|
|
4772
|
+
// Instanciado inicialmente com os headers da requisição original, para não perder nenhum header que já tenha sido adicionado
|
|
4773
|
+
let headers = req.headers;
|
|
4723
4774
|
// Adiciona as autenticações necessárias ao servidor. Autenticação básica.
|
|
4724
|
-
|
|
4775
|
+
// Daqui alguns dias este trecho será removido e os tokens serão enviados exclusivamente pelos Cookies, mas por enquanto, para manter compatibilidade com o que já existe, o token será enviado no header
|
|
4776
|
+
if (localStorage.getItem('configServerUser') && localStorage.getItem('configServerPassword')) {
|
|
4777
|
+
headers = req.headers.set("Authorization", `Basic ${btoa(`${localStorage.getItem('configServerUser')}:${localStorage.getItem('configServerPassword')}`)}
|
|
4725
4778
|
`);
|
|
4726
|
-
|
|
4779
|
+
}
|
|
4780
|
+
changedReq = req.clone({
|
|
4781
|
+
headers: headers,
|
|
4782
|
+
withCredentials: true // Parâmetro necessário para utilização dos Cookies HttpOnly
|
|
4783
|
+
});
|
|
4727
4784
|
}
|
|
4728
|
-
return next.handle(changedReq);
|
|
4785
|
+
// return next.handle(changedReq);
|
|
4786
|
+
// Exemplo de leitura de resposta via interceptor abaixo:
|
|
4787
|
+
return next.handle(changedReq)
|
|
4788
|
+
// INTERCEPTAR RESPOSTA
|
|
4789
|
+
.pipe(tap(event => {
|
|
4790
|
+
if (event instanceof HttpResponse) {
|
|
4791
|
+
console.log("Resposta HTTP interceptada:", event);
|
|
4792
|
+
}
|
|
4793
|
+
}),
|
|
4794
|
+
// INTERCEPTAR ERRO
|
|
4795
|
+
catchError(error => {
|
|
4796
|
+
console.error("Erro HTTP interceptado:", error);
|
|
4797
|
+
return throwError(() => error);
|
|
4798
|
+
}));
|
|
4729
4799
|
}
|
|
4730
4800
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthInfraInterceptor, deps: [{ token: i3.CheckUrlAndMethodService }, { token: LibCustomEnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4731
4801
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: AuthInfraInterceptor, providedIn: 'root' }); }
|
|
@@ -4760,20 +4830,32 @@ class SubMenuCardComponent {
|
|
|
4760
4830
|
// #region ==========> PROPERTIES <==========
|
|
4761
4831
|
// #region PUBLIC
|
|
4762
4832
|
this.subMenuCards = [];
|
|
4763
|
-
this.
|
|
4764
|
-
this.
|
|
4833
|
+
this.hostnameOS = "";
|
|
4834
|
+
this.hostnameV6 = "";
|
|
4835
|
+
this.getOutroModuloUrl = (url) => { return !this.hostnameV6.startsWith('https://') ? `https://${this.hostnameV6}/SisproErpCloud/${url}` : `${this.hostnameV6}/SisproErpCloud/${url}`; };
|
|
4836
|
+
this.getOutsystemsUrl = (url, isOutroModulo) => { return (isOutroModulo ? `${this.hostnameOS}/SisproErpCloud/${url}` : `${this.hostnameOS == "" ? `https://${window.location.host}` : this.hostnameOS}/${url}`); };
|
|
4765
4837
|
}
|
|
4766
4838
|
ngOnInit() {
|
|
4767
|
-
this.
|
|
4839
|
+
this.GetHostNameOS();
|
|
4840
|
+
this.GetHostNameV6();
|
|
4768
4841
|
}
|
|
4769
4842
|
// #region ==========> API METHODS <==========
|
|
4770
4843
|
// #region GET
|
|
4771
|
-
|
|
4844
|
+
GetHostNameOS() {
|
|
4772
4845
|
// Validação adicionada para ignorar esta chamada caso o componente seja exibido na docs
|
|
4773
4846
|
if (this._customEnv.product === "InfraCodeDocs")
|
|
4774
4847
|
return;
|
|
4775
4848
|
this._menuService.GetHostServerOutSystems().subscribe({
|
|
4776
|
-
next: response => this.
|
|
4849
|
+
next: response => this.hostnameOS = response.String,
|
|
4850
|
+
error: error => this._authUtilService.showHttpError(error)
|
|
4851
|
+
});
|
|
4852
|
+
}
|
|
4853
|
+
GetHostNameV6() {
|
|
4854
|
+
// Validação adicionada para ignorar esta chamada caso o componente seja exibido na docs
|
|
4855
|
+
if (this._customEnv.product === "InfraCodeDocs")
|
|
4856
|
+
return;
|
|
4857
|
+
this._menuService.GetHostServerV6().subscribe({
|
|
4858
|
+
next: response => this.hostnameV6 = response.String,
|
|
4777
4859
|
error: error => this._authUtilService.showHttpError(error)
|
|
4778
4860
|
});
|
|
4779
4861
|
}
|
|
@@ -4781,8 +4863,10 @@ class SubMenuCardComponent {
|
|
|
4781
4863
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.25", type: SubMenuCardComponent, isStandalone: true, selector: "sub-menu-card, lib-submenu-card", inputs: { subMenuCards: "subMenuCards" }, ngImport: i0, template: `
|
|
4782
4864
|
<div class="max-card-menu row">
|
|
4783
4865
|
@for(card of subMenuCards; track $index) {
|
|
4784
|
-
|
|
4785
|
-
|
|
4866
|
+
|
|
4867
|
+
<!-- VALIDAÇÃO DE 'IS_EXTERNAL' SIGNIFICA QUE A ROTA É OS -->
|
|
4868
|
+
@if (card.isExternal) {
|
|
4869
|
+
<a [href]="getOutsystemsUrl(card.urlPath, card.is_OutroModulo)" target="_blank" class="card-link col-4">
|
|
4786
4870
|
<div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
|
|
4787
4871
|
<div class="card-icon">
|
|
4788
4872
|
<div class="card-icon2">
|
|
@@ -4795,8 +4879,24 @@ class SubMenuCardComponent {
|
|
|
4795
4879
|
</div>
|
|
4796
4880
|
</a>
|
|
4797
4881
|
}
|
|
4882
|
+
<!-- VALIDAÇÃO DE 'IS_OUTROMODULO' SIGNIFICA QUE A ROTA É V6 PORÉM DE OUTRO PROJETO FRONTEND -->
|
|
4883
|
+
@else if (card.is_OutroModulo) {
|
|
4884
|
+
<a [href]="getOutroModuloUrl(card.urlPath)" target="_blank" class="card-link col-4">
|
|
4885
|
+
<div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
|
|
4886
|
+
<div class="card-icon">
|
|
4887
|
+
<div class="card-icon2">
|
|
4888
|
+
<lib-icon class="bold" [iconName]="card.icon ? card.icon : 'engrenagem'" iconColor="blue" [iconSize]="35" />
|
|
4889
|
+
</div>
|
|
4890
|
+
</div>
|
|
4891
|
+
|
|
4892
|
+
<h3 class="card-title">{{ card.titulo }}</h3>
|
|
4893
|
+
<p class="card-text" [title]="card.descricao"> {{ card.descricao }} </p>
|
|
4894
|
+
</div>
|
|
4895
|
+
</a>
|
|
4896
|
+
}
|
|
4897
|
+
<!-- CASO CONTRÁRIO DE TUDO SIGNIFICA QUE A ROTA É V6 E DENTRO DO MESMO MÓDULO -->
|
|
4798
4898
|
@else {
|
|
4799
|
-
<a
|
|
4899
|
+
<a routerLink="/{{ card.urlPath }}" class="card-link col-4">
|
|
4800
4900
|
<div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
|
|
4801
4901
|
<div class="card-icon">
|
|
4802
4902
|
<div class="card-icon2">
|
|
@@ -4821,8 +4921,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
4821
4921
|
], template: `
|
|
4822
4922
|
<div class="max-card-menu row">
|
|
4823
4923
|
@for(card of subMenuCards; track $index) {
|
|
4824
|
-
|
|
4825
|
-
|
|
4924
|
+
|
|
4925
|
+
<!-- VALIDAÇÃO DE 'IS_EXTERNAL' SIGNIFICA QUE A ROTA É OS -->
|
|
4926
|
+
@if (card.isExternal) {
|
|
4927
|
+
<a [href]="getOutsystemsUrl(card.urlPath, card.is_OutroModulo)" target="_blank" class="card-link col-4">
|
|
4928
|
+
<div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
|
|
4929
|
+
<div class="card-icon">
|
|
4930
|
+
<div class="card-icon2">
|
|
4931
|
+
<lib-icon class="bold" [iconName]="card.icon ? card.icon : 'engrenagem'" iconColor="blue" [iconSize]="35" />
|
|
4932
|
+
</div>
|
|
4933
|
+
</div>
|
|
4934
|
+
|
|
4935
|
+
<h3 class="card-title">{{ card.titulo }}</h3>
|
|
4936
|
+
<p class="card-text" [title]="card.descricao"> {{ card.descricao }} </p>
|
|
4937
|
+
</div>
|
|
4938
|
+
</a>
|
|
4939
|
+
}
|
|
4940
|
+
<!-- VALIDAÇÃO DE 'IS_OUTROMODULO' SIGNIFICA QUE A ROTA É V6 PORÉM DE OUTRO PROJETO FRONTEND -->
|
|
4941
|
+
@else if (card.is_OutroModulo) {
|
|
4942
|
+
<a [href]="getOutroModuloUrl(card.urlPath)" target="_blank" class="card-link col-4">
|
|
4826
4943
|
<div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
|
|
4827
4944
|
<div class="card-icon">
|
|
4828
4945
|
<div class="card-icon2">
|
|
@@ -4835,8 +4952,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
4835
4952
|
</div>
|
|
4836
4953
|
</a>
|
|
4837
4954
|
}
|
|
4955
|
+
<!-- CASO CONTRÁRIO DE TUDO SIGNIFICA QUE A ROTA É V6 E DENTRO DO MESMO MÓDULO -->
|
|
4838
4956
|
@else {
|
|
4839
|
-
<a
|
|
4957
|
+
<a routerLink="/{{ card.urlPath }}" class="card-link col-4">
|
|
4840
4958
|
<div class="card w-100 border-0 rounded text-center glb-cursor-pointer">
|
|
4841
4959
|
<div class="card-icon">
|
|
4842
4960
|
<div class="card-icon2">
|