ngx-vector-components 6.58.1 → 6.59.1
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/CHANGELOG.md +21 -0
- package/fesm2022/ngx-vector-components.mjs +259 -17
- package/fesm2022/ngx-vector-components.mjs.map +1 -1
- package/lib/config/index.d.ts +10 -1
- package/lib/guards/crud-list-has-items.guard.d.ts +7 -0
- package/lib/guards/has-permission.guard.d.ts +7 -1
- package/lib/guards/token-is-present.guard.d.ts +4 -0
- package/lib/services/analytics.service.d.ts +1 -1
- package/lib/services/auth.service.d.ts +34 -0
- package/lib/services/profile.service.d.ts +22 -0
- package/lib/services/storage.service.d.ts +27 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.59.1] (27/11/2026)
|
|
4
|
+
|
|
5
|
+
### Fix
|
|
6
|
+
|
|
7
|
+
- Session credentials (`token`, `refreshToken`, `username`) moved to sessionStorage, so closing every tab or the browser ends the session. What earlier versions left in localStorage is erased on first read (`storage.service.ts`)
|
|
8
|
+
- `AuthService.adoptSessionFromLiveTab()`: a tab that starts without a session asks live tabs for it over a same-origin `BroadcastChannel` and gets the whole sessionStorage back, which keeps duplication working on Firefox and Safari. A tab that already has a session asks nothing (`auth.service.ts`)
|
|
9
|
+
- `AuthService.logout()`: announced on the same channel, so leaving from one tab signs out all of them. Each tab only cleared its own sessionStorage before (`auth.service.ts`)
|
|
10
|
+
- `ProfileService.refreshFromStorage()`: rereads what the service keeps in memory — modules, user name, profile flags — after a session arrives from another tab. The constructor had already run on an empty storage, leaving the top bar without the user's name (`profile.service.ts`)
|
|
11
|
+
- `tokenIsPresentGuard`: calls `logout()` instead of returning `false`, which only cancelled the navigation and left a blank screen; the user now lands on the environment's login. Stays synchronous, since the route reruns it on every parameter change (`token-is-present.guard.ts`)
|
|
12
|
+
- `provideSessionSync()`: APP_INITIALIZER that runs the adoption before the guards. **Every app must register it** (`config/index.ts`)
|
|
13
|
+
|
|
14
|
+
## [6.59.0] (26/11/2026)
|
|
15
|
+
|
|
16
|
+
### Fix
|
|
17
|
+
|
|
18
|
+
- Corrects duplicating a tab, reloading the page or opening a screen from its URL left the top bar and the menu on screen but no content. Three guards were reading state that only exists in memory:
|
|
19
|
+
- `ProfileService.ensureProfileLoaded()`: fetches the profile when it is missing, and resolves synchronously when it is already loaded, so navigation gains no latency. It was only loaded through `getTokenByGuid`, so a start without a token in the URL never fetched permissions again (`profile.service.ts`)
|
|
20
|
+
- `hasPermissionGuard`: waits for the profile before deciding. A missing profile is not a denied permission (`has-permission.guard.ts`)
|
|
21
|
+
- `crudListHasItemsGuard`: a route carrying a URL parameter goes through, since the screen loads from that id and does not depend on `dataset$`, which starts empty on every load (`crud-list-has-items.guard.ts`)
|
|
22
|
+
- `StorageService`: `refreshToken` and `username` moved from sessionStorage to localStorage, next to the token they renew. Firefox and Safari do not copy the session when a tab is duplicated, so the new tab had no way to renew the token and the first 401 logged the user out. Values left in the old place are migrated on read (`storage.service.ts`)
|
|
23
|
+
|
|
3
24
|
## [6.58.1] (26/11/2026)
|
|
4
25
|
|
|
5
26
|
### Fix
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Input, Component, Pipe, NgModule, Directive, InjectionToken, Injectable, Inject, EventEmitter, HostBinding, Output, booleanAttribute, ContentChildren, ContentChild, ViewChild, Optional, signal, ViewEncapsulation, inject, HostListener, input, output } from '@angular/core';
|
|
2
|
+
import { Input, Component, Pipe, NgModule, Directive, InjectionToken, Injectable, Inject, EventEmitter, HostBinding, Output, booleanAttribute, ContentChildren, ContentChild, ViewChild, Optional, signal, ViewEncapsulation, inject, HostListener, input, output, APP_INITIALIZER } from '@angular/core';
|
|
3
3
|
import * as i1 from 'primeng/accordion';
|
|
4
4
|
import { AccordionModule as AccordionModule$1 } from 'primeng/accordion';
|
|
5
5
|
import * as i1$1 from '@angular/common';
|
|
@@ -63,7 +63,7 @@ import { Tabs, TabsModule as TabsModule$1 } from 'primeng/tabs';
|
|
|
63
63
|
import { DateTime } from 'luxon';
|
|
64
64
|
import * as i1$5 from '@angular/common/http';
|
|
65
65
|
import { HttpHeaders, HttpClient, HttpResponse } from '@angular/common/http';
|
|
66
|
-
import { switchMap, map, tap,
|
|
66
|
+
import { switchMap, map, tap, catchError, shareReplay, debounceTime, finalize, filter, take } from 'rxjs/operators';
|
|
67
67
|
import * as i1$7 from '@angular/platform-browser';
|
|
68
68
|
import * as i1$8 from 'primeng/drawer';
|
|
69
69
|
import { DrawerModule as DrawerModule$1 } from 'primeng/drawer';
|
|
@@ -2399,17 +2399,47 @@ class StorageService {
|
|
|
2399
2399
|
removeSession(key) {
|
|
2400
2400
|
sessionStorage.removeItem(key);
|
|
2401
2401
|
}
|
|
2402
|
+
/**
|
|
2403
|
+
* Copia da sessao desta aba, para outra adotar inteira.
|
|
2404
|
+
*
|
|
2405
|
+
* Vai tudo, nao so as credenciais: com o perfil junto a aba nova monta a
|
|
2406
|
+
* primeira tela sem ir ao servidor, e os filtros de grid fazem ela abrir
|
|
2407
|
+
* igual a original.
|
|
2408
|
+
*/
|
|
2409
|
+
snapshotSession() {
|
|
2410
|
+
const snapshot = {};
|
|
2411
|
+
for (let index = 0; index < sessionStorage.length; index++) {
|
|
2412
|
+
const key = sessionStorage.key(index);
|
|
2413
|
+
if (key) {
|
|
2414
|
+
snapshot[key] = sessionStorage.getItem(key) ?? '';
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
return snapshot;
|
|
2418
|
+
}
|
|
2419
|
+
/** Aplica o que {@link snapshotSession} produziu em outra aba. */
|
|
2420
|
+
restoreSession(snapshot) {
|
|
2421
|
+
Object.entries(snapshot).forEach(([key, value]) => sessionStorage.setItem(key, value));
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Credenciais no sessionStorage, nunca no localStorage: morrem com a aba, e
|
|
2425
|
+
* fechar o navegador encerra a sessao. No localStorage ficavam no perfil do
|
|
2426
|
+
* navegador por tempo indefinido, e bastava colar a URL para entrar.
|
|
2427
|
+
*
|
|
2428
|
+
* A aba duplicada no Firefox e no Safari, que nao copiam a sessao, recebe as
|
|
2429
|
+
* credenciais de uma aba viva por `AuthService.adoptSessionFromLiveTab`.
|
|
2430
|
+
*/
|
|
2402
2431
|
getToken() {
|
|
2403
|
-
return
|
|
2432
|
+
return this.readDiscardingPersisted('token');
|
|
2404
2433
|
}
|
|
2405
2434
|
setToken(token) {
|
|
2406
|
-
|
|
2435
|
+
sessionStorage.setItem('token', token);
|
|
2407
2436
|
}
|
|
2408
2437
|
removeToken() {
|
|
2409
|
-
|
|
2438
|
+
sessionStorage.removeItem('token');
|
|
2410
2439
|
}
|
|
2440
|
+
/** O {@link getUsername} acompanha: `getTokenByRefreshToken` o envia na renovacao. */
|
|
2411
2441
|
getRefreshToken() {
|
|
2412
|
-
return
|
|
2442
|
+
return this.readDiscardingPersisted('refreshToken');
|
|
2413
2443
|
}
|
|
2414
2444
|
setRefreshToken(refreshToken) {
|
|
2415
2445
|
sessionStorage.setItem('refreshToken', refreshToken);
|
|
@@ -2418,7 +2448,7 @@ class StorageService {
|
|
|
2418
2448
|
sessionStorage.removeItem('refreshToken');
|
|
2419
2449
|
}
|
|
2420
2450
|
getUsername() {
|
|
2421
|
-
return
|
|
2451
|
+
return this.readDiscardingPersisted('username');
|
|
2422
2452
|
}
|
|
2423
2453
|
setUsername(username) {
|
|
2424
2454
|
sessionStorage.setItem('username', username);
|
|
@@ -2426,6 +2456,26 @@ class StorageService {
|
|
|
2426
2456
|
removeUsername() {
|
|
2427
2457
|
sessionStorage.removeItem('username');
|
|
2428
2458
|
}
|
|
2459
|
+
/**
|
|
2460
|
+
* Le do sessionStorage e, se a chave tiver ficado no localStorage de uma
|
|
2461
|
+
* versao que guardava credenciais la, move e apaga a copia persistida — sem
|
|
2462
|
+
* isso o token continuaria no disco mesmo depois desta mudanca.
|
|
2463
|
+
*
|
|
2464
|
+
* Pode sair quando nao houver mais sessoes daquela epoca em circulacao.
|
|
2465
|
+
*/
|
|
2466
|
+
readDiscardingPersisted(key) {
|
|
2467
|
+
const stored = sessionStorage.getItem(key);
|
|
2468
|
+
if (stored) {
|
|
2469
|
+
return stored;
|
|
2470
|
+
}
|
|
2471
|
+
const persisted = localStorage.getItem(key);
|
|
2472
|
+
if (!persisted) {
|
|
2473
|
+
return '';
|
|
2474
|
+
}
|
|
2475
|
+
sessionStorage.setItem(key, persisted);
|
|
2476
|
+
localStorage.removeItem(key);
|
|
2477
|
+
return persisted;
|
|
2478
|
+
}
|
|
2429
2479
|
getUserId() {
|
|
2430
2480
|
const userId = sessionStorage.getItem('userId');
|
|
2431
2481
|
return userId ? +atob(userId) : 0;
|
|
@@ -2506,7 +2556,7 @@ class AnalyticsService {
|
|
|
2506
2556
|
}
|
|
2507
2557
|
/**
|
|
2508
2558
|
* NAO INTERATIVO -- o sistema respondeu ou exibiu algo: resultado carregado,
|
|
2509
|
-
|
|
2559
|
+
* lista vazia, erro de negocio, modal automatico.
|
|
2510
2560
|
*
|
|
2511
2561
|
* @example this.analyticsService.appEvent('heat_map_empty', { context: { points: 0 } });
|
|
2512
2562
|
*/
|
|
@@ -2685,6 +2735,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
2685
2735
|
}] }] });
|
|
2686
2736
|
|
|
2687
2737
|
class AuthService {
|
|
2738
|
+
static { this.SESSION_CHANNEL = 'vector-session'; }
|
|
2739
|
+
/**
|
|
2740
|
+
* Teto da espera por uma aba viva, nao o custo normal: havendo alguma, a
|
|
2741
|
+
* resposta chega em poucos milissegundos. Quem ja tem sessao nao pergunta.
|
|
2742
|
+
*/
|
|
2743
|
+
static { this.SESSION_ANSWER_MS = 150; }
|
|
2688
2744
|
constructor(environment, http, storageService, profileService, activatedRoute) {
|
|
2689
2745
|
this.environment = environment;
|
|
2690
2746
|
this.http = http;
|
|
@@ -2701,6 +2757,91 @@ class AuthService {
|
|
|
2701
2757
|
}
|
|
2702
2758
|
}));
|
|
2703
2759
|
}
|
|
2760
|
+
/**
|
|
2761
|
+
* Traz a sessao de uma aba viva, no bootstrap.
|
|
2762
|
+
*
|
|
2763
|
+
* As credenciais vivem no sessionStorage, que morre com a aba — fechadas
|
|
2764
|
+
* todas, o login e exigido. O Firefox e o Safari nao a copiam ao duplicar, e
|
|
2765
|
+
* dai a aba nova a pede pelo `BroadcastChannel`, restrito a mesma origem.
|
|
2766
|
+
*
|
|
2767
|
+
* **Quem ja tem sessao nao pergunta nada**, por isso nada e somado ao
|
|
2768
|
+
* carregamento. Restaurar abas devolve o sessionStorage e mantem o login:
|
|
2769
|
+
* distinguir isso exigia o handshake sempre, e o custo nao se justificou.
|
|
2770
|
+
*/
|
|
2771
|
+
async adoptSessionFromLiveTab() {
|
|
2772
|
+
if (typeof BroadcastChannel === 'undefined') {
|
|
2773
|
+
return;
|
|
2774
|
+
}
|
|
2775
|
+
this.sessionChannel = new BroadcastChannel(AuthService.SESSION_CHANNEL);
|
|
2776
|
+
this.offerSessionToNewTabs();
|
|
2777
|
+
// Sessao em maos: nada a pedir, e nada a esperar.
|
|
2778
|
+
if (this.storageService.getToken()) {
|
|
2779
|
+
return;
|
|
2780
|
+
}
|
|
2781
|
+
// Entrada pelo portal: a sessao nasce aqui, nao vem de outra aba.
|
|
2782
|
+
if (this.hasEntryTokenInUrl()) {
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
const offer = await this.requestSessionFromLiveTab();
|
|
2786
|
+
if (!offer) {
|
|
2787
|
+
return;
|
|
2788
|
+
}
|
|
2789
|
+
this.storageService.restoreSession(offer.session);
|
|
2790
|
+
// O ProfileService ja foi construido, com a sessao ainda vazia. Sem reler o
|
|
2791
|
+
// storage, o perfil recem-adotado seria ignorado: o guard buscaria
|
|
2792
|
+
// `userinfo` no servidor e o nome do usuario nao apareceria no topo.
|
|
2793
|
+
this.profileService.refreshFromStorage();
|
|
2794
|
+
}
|
|
2795
|
+
/** Token de uso unico que o portal injeta ao abrir o sistema. */
|
|
2796
|
+
hasEntryTokenInUrl() {
|
|
2797
|
+
const params = new URLSearchParams(window.location.search);
|
|
2798
|
+
return params.has('Token') || params.has('tokenGuid');
|
|
2799
|
+
}
|
|
2800
|
+
/**
|
|
2801
|
+
* Atende as outras abas: entrega a sessao a quem chega, acompanha o logout de
|
|
2802
|
+
* quem sai. O logout viaja pelo canal porque cada aba tem o proprio
|
|
2803
|
+
* sessionStorage, e limpar o desta nao alcanca as demais.
|
|
2804
|
+
*/
|
|
2805
|
+
offerSessionToNewTabs() {
|
|
2806
|
+
this.sessionChannel?.addEventListener('message', (event) => {
|
|
2807
|
+
if (event.data?.type === 'logout') {
|
|
2808
|
+
this.endSession();
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2811
|
+
if (event.data?.type !== 'request' || !this.storageService.getToken()) {
|
|
2812
|
+
return;
|
|
2813
|
+
}
|
|
2814
|
+
// A sessao inteira, e nao so as credenciais: com o perfil junto a aba
|
|
2815
|
+
// nova monta a primeira tela sem ir ao servidor buscar `userinfo`.
|
|
2816
|
+
this.sessionChannel?.postMessage({
|
|
2817
|
+
type: 'offer',
|
|
2818
|
+
session: this.storageService.snapshotSession(),
|
|
2819
|
+
});
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2822
|
+
requestSessionFromLiveTab() {
|
|
2823
|
+
return new Promise((resolve) => {
|
|
2824
|
+
let settled = false;
|
|
2825
|
+
const finish = (offer) => {
|
|
2826
|
+
if (settled) {
|
|
2827
|
+
return;
|
|
2828
|
+
}
|
|
2829
|
+
settled = true;
|
|
2830
|
+
this.sessionChannel?.removeEventListener('message', onMessage);
|
|
2831
|
+
clearTimeout(timer);
|
|
2832
|
+
resolve(offer);
|
|
2833
|
+
};
|
|
2834
|
+
const onMessage = (event) => {
|
|
2835
|
+
const data = event.data;
|
|
2836
|
+
if (data?.type === 'offer' && data.session?.['token']) {
|
|
2837
|
+
finish(data);
|
|
2838
|
+
}
|
|
2839
|
+
};
|
|
2840
|
+
const timer = setTimeout(() => finish(null), AuthService.SESSION_ANSWER_MS);
|
|
2841
|
+
this.sessionChannel?.addEventListener('message', onMessage);
|
|
2842
|
+
this.sessionChannel?.postMessage({ type: 'request' });
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2704
2845
|
getTokenByGuid(tokenGuid) {
|
|
2705
2846
|
let response;
|
|
2706
2847
|
return this.http.get(`${this.baseUrl}/TemporaryAccessToken/${tokenGuid}`).pipe(switchMap((tokenResponse) => {
|
|
@@ -2733,7 +2874,16 @@ class AuthService {
|
|
|
2733
2874
|
})
|
|
2734
2875
|
.pipe(map((response) => response?.accessToken || ''));
|
|
2735
2876
|
}
|
|
2877
|
+
/**
|
|
2878
|
+
* Encerra a sessao em todas as abas. O canal nao entrega ao proprio emissor,
|
|
2879
|
+
* entao a mensagem vai as outras e esta se encerra em seguida, sem eco.
|
|
2880
|
+
*/
|
|
2736
2881
|
logout() {
|
|
2882
|
+
this.sessionChannel?.postMessage({ type: 'logout' });
|
|
2883
|
+
this.endSession();
|
|
2884
|
+
}
|
|
2885
|
+
/** Limpa a sessao desta aba e manda o usuario para o login. */
|
|
2886
|
+
endSession() {
|
|
2737
2887
|
this.storageService.clear();
|
|
2738
2888
|
if (window.parent == window) {
|
|
2739
2889
|
window.location.href = this.environment.PORTAL_URL;
|
|
@@ -2861,7 +3011,24 @@ class ProfileService {
|
|
|
2861
3011
|
this.hasMarketplaceAdminPermission = false;
|
|
2862
3012
|
this.hasAnyFintechPermission = false;
|
|
2863
3013
|
this.hasAnyMarketplacePermission = false;
|
|
2864
|
-
|
|
3014
|
+
this.refreshFromStorage();
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Relê do storage tudo o que este serviço guarda em memória.
|
|
3018
|
+
*
|
|
3019
|
+
* Chamar depois de a sessão chegar de outra aba: o construtor já rodou com o
|
|
3020
|
+
* storage vazio, e sem isto o nome no topo da tela, os módulos e as flags de
|
|
3021
|
+
* perfil ficariam indefinidos.
|
|
3022
|
+
*/
|
|
3023
|
+
refreshFromStorage() {
|
|
3024
|
+
const { fintech, marketplace, allModules } = this.storageService.getProfile();
|
|
3025
|
+
const userInfo = this.storageService.getSession('userInfo');
|
|
3026
|
+
this.moduleProfile$.next(allModules);
|
|
3027
|
+
this.profileFirstName.set(userInfo?.userName);
|
|
3028
|
+
this.profileFirstName$.next(userInfo?.userName);
|
|
3029
|
+
if (userInfo) {
|
|
3030
|
+
this.profileTypeItens$.next(userInfo);
|
|
3031
|
+
}
|
|
2865
3032
|
this.hasFintechAdminPermission = !!fintech?.actions.some((act) => [
|
|
2866
3033
|
ProfileModuleActionType.FINTECH_BANK_ADMIN.toString(),
|
|
2867
3034
|
ProfileModuleActionType.FINTECH_CREDIT_ADMIN.toString(),
|
|
@@ -2920,6 +3087,30 @@ class ProfileService {
|
|
|
2920
3087
|
this.moduleProfile$.next(allModules);
|
|
2921
3088
|
}));
|
|
2922
3089
|
}
|
|
3090
|
+
/**
|
|
3091
|
+
* Garante o perfil disponível antes de alguém decidir com base nele.
|
|
3092
|
+
*
|
|
3093
|
+
* Com ele em mãos devolve de forma síncrona, sem requisição. Sem ele, busca
|
|
3094
|
+
* uma vez: o `getTokenByGuid` era o único lugar que o carregava, então uma
|
|
3095
|
+
* aplicação que subia sem token na URL ficava sem como buscá-lo.
|
|
3096
|
+
*
|
|
3097
|
+
* O `shareReplay` faz navegações simultâneas dividirem a mesma requisição.
|
|
3098
|
+
* Erro devolve indefinido, e quem chamou nega; o cache é descartado nesse
|
|
3099
|
+
* caso, senão uma falha passageira ficaria gravada para sempre.
|
|
3100
|
+
*/
|
|
3101
|
+
ensureProfileLoaded() {
|
|
3102
|
+
if (this.moduleProfile$.value) {
|
|
3103
|
+
return of(this.moduleProfile$.value);
|
|
3104
|
+
}
|
|
3105
|
+
if (!this.storageService.getToken()) {
|
|
3106
|
+
return of(undefined);
|
|
3107
|
+
}
|
|
3108
|
+
this.profileRequest$ ??= this.getUserProfile().pipe(map(() => this.moduleProfile$.value), catchError(() => {
|
|
3109
|
+
this.profileRequest$ = undefined;
|
|
3110
|
+
return of(undefined);
|
|
3111
|
+
}), shareReplay(1));
|
|
3112
|
+
return this.profileRequest$;
|
|
3113
|
+
}
|
|
2923
3114
|
userHasPermission(action) {
|
|
2924
3115
|
if (!action) {
|
|
2925
3116
|
return true;
|
|
@@ -7603,8 +7794,34 @@ function provideVectorPrimeNG() {
|
|
|
7603
7794
|
ripple: true,
|
|
7604
7795
|
});
|
|
7605
7796
|
}
|
|
7797
|
+
/**
|
|
7798
|
+
* Traz a sessão de uma aba viva, antes dos guards — que já leem o token para
|
|
7799
|
+
* decidir. Ver `AuthService.adoptSessionFromLiveTab`.
|
|
7800
|
+
*
|
|
7801
|
+
* Use no array `providers` do AppModule de cada projeto:
|
|
7802
|
+
*
|
|
7803
|
+
* providers: [provideSessionSync(), ...]
|
|
7804
|
+
*/
|
|
7805
|
+
function provideSessionSync() {
|
|
7806
|
+
return {
|
|
7807
|
+
provide: APP_INITIALIZER,
|
|
7808
|
+
multi: true,
|
|
7809
|
+
useFactory: (authService) => () => authService.adoptSessionFromLiveTab(),
|
|
7810
|
+
deps: [AuthService],
|
|
7811
|
+
};
|
|
7812
|
+
}
|
|
7606
7813
|
|
|
7814
|
+
/**
|
|
7815
|
+
* Deixa a rota abrir quando a lista do CRUD já foi carregada em memória.
|
|
7816
|
+
*
|
|
7817
|
+
* Rota com parâmetro passa direto: a tela se carrega pelo id da URL e não
|
|
7818
|
+
* depende do `dataset$`, que nasce vazio a cada carga. Sem essa saída, abrir um
|
|
7819
|
+
* detalhe por link, favorito ou aba duplicada voltava para a listagem.
|
|
7820
|
+
*/
|
|
7607
7821
|
const crudListHasItemsGuard = (routeSnapshot) => {
|
|
7822
|
+
if (Object.keys(routeSnapshot.params).length) {
|
|
7823
|
+
return true;
|
|
7824
|
+
}
|
|
7608
7825
|
const serviceType = routeSnapshot.data['service'];
|
|
7609
7826
|
if (!serviceType) {
|
|
7610
7827
|
console.error('You forgot to add the service declaration to route "data" property.');
|
|
@@ -7649,15 +7866,25 @@ const getTokenByGuidGuard = (route) => {
|
|
|
7649
7866
|
return false;
|
|
7650
7867
|
};
|
|
7651
7868
|
|
|
7869
|
+
/**
|
|
7870
|
+
* Libera a rota conforme as permissões do perfil.
|
|
7871
|
+
*
|
|
7872
|
+
* Espera o perfil antes de decidir: ausente não é o mesmo que negado. Com ele
|
|
7873
|
+
* já carregado, `ensureProfileLoaded` responde de forma síncrona.
|
|
7874
|
+
*/
|
|
7652
7875
|
const hasPermissionGuard = (routeSnapshot) => {
|
|
7653
7876
|
const profileService = inject(ProfileService);
|
|
7654
7877
|
const router = inject(Router);
|
|
7655
7878
|
const appName = inject(APP_NAME);
|
|
7656
|
-
const
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7879
|
+
const decide = () => profileService.userHasPermission(routeSnapshot.data['permission'])
|
|
7880
|
+
? true
|
|
7881
|
+
: router.createUrlTree([appName.toLowerCase()]);
|
|
7882
|
+
// Caminho de quase toda navegacao: responde sem Observable nenhum, para o
|
|
7883
|
+
// router resolver a rota no mesmo ciclo.
|
|
7884
|
+
if (profileService.moduleProfile$.value) {
|
|
7885
|
+
return decide();
|
|
7886
|
+
}
|
|
7887
|
+
return profileService.ensureProfileLoaded().pipe(map(decide));
|
|
7661
7888
|
};
|
|
7662
7889
|
|
|
7663
7890
|
const roleGuard = (routeSnapshot) => {
|
|
@@ -7670,15 +7897,30 @@ const roleGuard = (routeSnapshot) => {
|
|
|
7670
7897
|
return router.createUrlTree(['']);
|
|
7671
7898
|
};
|
|
7672
7899
|
|
|
7900
|
+
/**
|
|
7901
|
+
* Exige token para a rota. Cobre as rotas raiz, logo vale para todas as telas
|
|
7902
|
+
* abaixo delas.
|
|
7903
|
+
*/
|
|
7673
7904
|
const tokenIsPresentGuard = (routeSnapshot) => {
|
|
7674
7905
|
const storageService = inject(StorageService);
|
|
7675
7906
|
const authService = inject(AuthService);
|
|
7907
|
+
// Este caminho ja carrega o perfil: `getTokenByGuid` encadeia `getUserProfile`.
|
|
7676
7908
|
if (routeSnapshot.queryParams['tokenGuid']) {
|
|
7677
7909
|
return firstValueFrom(authService.getTokenByGuid(routeSnapshot.queryParams['tokenGuid'])).then((response) => !!response.accessToken);
|
|
7678
7910
|
}
|
|
7679
|
-
|
|
7680
|
-
|
|
7911
|
+
// `logout()` e nao `false`: devolver false apenas cancela a navegacao — o
|
|
7912
|
+
// router nao vai a lugar nenhum, a URL volta para a raiz e nada e montado,
|
|
7913
|
+
// deixando a tela em branco. O logout leva ao PORTAL_URL do ambiente, que e
|
|
7914
|
+
// onde o login mora em qualquer instalacao.
|
|
7915
|
+
if (!storageService.getToken()) {
|
|
7916
|
+
authService.logout();
|
|
7917
|
+
return false;
|
|
7681
7918
|
}
|
|
7919
|
+
// Sincrono de proposito. Esta rota roda com `runGuardsAndResolvers` em cada
|
|
7920
|
+
// mudanca de parametro, entao qualquer coisa assincrona aqui entra no caminho
|
|
7921
|
+
// de toda navegacao. O perfil ja vem junto da sessao adotada de outra aba, e
|
|
7922
|
+
// o `hasPermissionGuard` cobre quem chegar sem ele.
|
|
7923
|
+
return true;
|
|
7682
7924
|
};
|
|
7683
7925
|
|
|
7684
7926
|
class HttpInterceptorProvider {
|
|
@@ -7952,5 +8194,5 @@ const getSelectedCrudItemResolver = (routeSnapshot) => {
|
|
|
7952
8194
|
* Generated bundle index. Do not edit.
|
|
7953
8195
|
*/
|
|
7954
8196
|
|
|
7955
|
-
export { APP_NAME, AccordionComponent, AccordionModule, AnalyticsService, AppName, AuthService, BadgeComponent, BadgeModule, BooleanType, BreadcrumbComponent, BreadcrumbModule, BreadcrumbService, ButtonComponent, CalendarComponent, CheckboxFieldComponent, CpfCnpjValidator, CrudBaseComponent, CrudBaseService, CrudFooterComponent, CrudHeaderComponent, CrudHeaderModule, CrudHistory, CrudHistoryComponent, CrudHistoryModule, CrudMode, CurrencyBrlPipe, CurrencyFieldComponent, CustomHeaderDirective, DataTableComponent, DocumentType, DrawerComponent, DrawerModule, DropdownFieldComponent, ENVIRONMENT, EnumService, ErrorMessageService, FieldErrorMessageComponent, FieldType, FieldsModule, FileUtil, FiltersComponent, FooterModule, FormatDocumentPipe, GenericErrorModalComponent, GenericErrorModalModule, GenericModalComponent, GenericModalModule, GeolocationService, HttpInterceptorProvider, INPUT_FILE_ACCEPT_EXTENSIONS, InputFileComponent, InputNumberFieldComponent, InputOtpComponent, InputSwitchFieldComponent, LoadingService, MENU_OPTIONS, MaskPipe, MaskUtil, MenuComponent, MenuModule, MenuService, MessageStatus, ModalService, MultiselectFieldComponent, NotHiddenPipe, NotificationsService, ObjectUtil, OnlyActivePipe, PanelComponent, PanelModule, PercentageFieldComponent, PipesModule, ProfileModuleActionType, ProfileModuleType, ProfileService, ProfileTypeEnum, RadioButtonFieldComponent, RangeValueComponent, RemoveLastChildPipe, Role, ScoreComponent, ScoreModule, SearchFieldComponent, SelectButtonFieldComponent, SelectionType, SnackbarComponent, SnackbarModule, Status, StepperComponent, StepperModule, StorageService, StringUtil, SubMenusListComponent, TabPanelComponent, TableColumnType, TabsComponent, TabsModule, TextFieldComponent, TextareaFieldComponent, TopBarComponent, TopBarModule, UnreadNotificationsPipe, ValidationUtil, VectorPreset, View, WindowUtil, createUploadMultipleForm, createUploadSingleForm, crudListHasItemsGuard, getSelectedCrudItemResolver, getTokenByGuidGuard, hasPermissionGuard, provideVectorPrimeNG, roleGuard, tokenIsPresentGuard };
|
|
8197
|
+
export { APP_NAME, AccordionComponent, AccordionModule, AnalyticsService, AppName, AuthService, BadgeComponent, BadgeModule, BooleanType, BreadcrumbComponent, BreadcrumbModule, BreadcrumbService, ButtonComponent, CalendarComponent, CheckboxFieldComponent, CpfCnpjValidator, CrudBaseComponent, CrudBaseService, CrudFooterComponent, CrudHeaderComponent, CrudHeaderModule, CrudHistory, CrudHistoryComponent, CrudHistoryModule, CrudMode, CurrencyBrlPipe, CurrencyFieldComponent, CustomHeaderDirective, DataTableComponent, DocumentType, DrawerComponent, DrawerModule, DropdownFieldComponent, ENVIRONMENT, EnumService, ErrorMessageService, FieldErrorMessageComponent, FieldType, FieldsModule, FileUtil, FiltersComponent, FooterModule, FormatDocumentPipe, GenericErrorModalComponent, GenericErrorModalModule, GenericModalComponent, GenericModalModule, GeolocationService, HttpInterceptorProvider, INPUT_FILE_ACCEPT_EXTENSIONS, InputFileComponent, InputNumberFieldComponent, InputOtpComponent, InputSwitchFieldComponent, LoadingService, MENU_OPTIONS, MaskPipe, MaskUtil, MenuComponent, MenuModule, MenuService, MessageStatus, ModalService, MultiselectFieldComponent, NotHiddenPipe, NotificationsService, ObjectUtil, OnlyActivePipe, PanelComponent, PanelModule, PercentageFieldComponent, PipesModule, ProfileModuleActionType, ProfileModuleType, ProfileService, ProfileTypeEnum, RadioButtonFieldComponent, RangeValueComponent, RemoveLastChildPipe, Role, ScoreComponent, ScoreModule, SearchFieldComponent, SelectButtonFieldComponent, SelectionType, SnackbarComponent, SnackbarModule, Status, StepperComponent, StepperModule, StorageService, StringUtil, SubMenusListComponent, TabPanelComponent, TableColumnType, TabsComponent, TabsModule, TextFieldComponent, TextareaFieldComponent, TopBarComponent, TopBarModule, UnreadNotificationsPipe, ValidationUtil, VectorPreset, View, WindowUtil, createUploadMultipleForm, createUploadSingleForm, crudListHasItemsGuard, getSelectedCrudItemResolver, getTokenByGuidGuard, hasPermissionGuard, provideSessionSync, provideVectorPrimeNG, roleGuard, tokenIsPresentGuard };
|
|
7956
8198
|
//# sourceMappingURL=ngx-vector-components.mjs.map
|