ngx-sp-auth 4.23.8 → 4.23.9
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
CHANGED
|
@@ -7,7 +7,7 @@ import { MsalInterceptor, MsalGuard, MsalModule, MSAL_GUARD_CONFIG } from '@azur
|
|
|
7
7
|
import { LogLevel, PublicClientApplication, InteractionType } from '@azure/msal-browser';
|
|
8
8
|
import { take as take$1, tap as tap$1, map as map$1, switchMap as switchMap$1 } from 'rxjs/operators';
|
|
9
9
|
import * as i1$1 from '@angular/router';
|
|
10
|
-
import { RouterLink, NavigationEnd, RouterOutlet } from '@angular/router';
|
|
10
|
+
import { RouterLink, NavigationEnd, RouterOutlet, Router, PRIMARY_OUTLET } from '@angular/router';
|
|
11
11
|
import * as i3 from 'ngx-sp-infra';
|
|
12
12
|
import { IpServiceService, Utils, SearchInputComponent, InfraModule, FormUtils, Usuario, RetPasswordPolicy, RetCheckPassword, CheckPasswordRecord, PasswordPolicyComponent, LibIconsComponent, ContentContainerComponent } from 'ngx-sp-infra';
|
|
13
13
|
import * as i10 from 'ngx-toastr';
|
|
@@ -832,7 +832,7 @@ class AuthStorageService {
|
|
|
832
832
|
const url = `${this._BASE_VERIFICATION_URL}`;
|
|
833
833
|
const headers = this._HTTP_HEADERS.set('x-application', this._customEnvironmentService.product);
|
|
834
834
|
return defer(() => {
|
|
835
|
-
this._toastr.info('Validando token do usuário.', 'Aguarde...'
|
|
835
|
+
this._toastr.info('Validando token do usuário.', 'Aguarde...');
|
|
836
836
|
const params = new HttpParams()
|
|
837
837
|
.set('ip', this.ip)
|
|
838
838
|
.set('browser', this._ipService.getDataBrowserUser().browser);
|
|
@@ -4688,6 +4688,81 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
4688
4688
|
args: [{ providedIn: 'root' }]
|
|
4689
4689
|
}], ctorParameters: () => [{ type: i1$1.Router }, { type: MenuServicesService }] });
|
|
4690
4690
|
|
|
4691
|
+
const IsMenuAllowedGuard = (_route, state) => {
|
|
4692
|
+
const router = inject(Router);
|
|
4693
|
+
const menuService = inject(MenuServicesService);
|
|
4694
|
+
const navigateToError = () => {
|
|
4695
|
+
return router.createUrlTree(['/error-menu-not-allowed']);
|
|
4696
|
+
};
|
|
4697
|
+
const permissionRoute = getPermissionRoute(state);
|
|
4698
|
+
// console.log('permissionRoute:', permissionRoute);
|
|
4699
|
+
return menuService.isMenuAllowed(permissionRoute).pipe(map(response => {
|
|
4700
|
+
// console.log('isMenuAllowed.response:', response);
|
|
4701
|
+
if (response.IsMenuAllowed)
|
|
4702
|
+
return true;
|
|
4703
|
+
return navigateToError();
|
|
4704
|
+
}), catchError(() => {
|
|
4705
|
+
return of(navigateToError());
|
|
4706
|
+
}));
|
|
4707
|
+
};
|
|
4708
|
+
/**
|
|
4709
|
+
* Obtém a rota utilizada para validar a permissão.
|
|
4710
|
+
*
|
|
4711
|
+
* Regras:
|
|
4712
|
+
* - considera toda a rota ativa, inclusive rotas lazy-loaded;
|
|
4713
|
+
* - ignora query parameters e fragments;
|
|
4714
|
+
* - ignora parâmetros declarados com ":";
|
|
4715
|
+
* - ignora qualquer segmento posterior ao primeiro parâmetro;
|
|
4716
|
+
* - retorna a rota sem "/" inicial.
|
|
4717
|
+
*
|
|
4718
|
+
* Exemplos:
|
|
4719
|
+
*
|
|
4720
|
+
* movimentacoes/alteracao-cadastral-grupo
|
|
4721
|
+
* => movimentacoes/alteracao-cadastral-grupo
|
|
4722
|
+
*
|
|
4723
|
+
* movimentacoes/fluxos-gerais/:id
|
|
4724
|
+
* => movimentacoes/fluxos-gerais
|
|
4725
|
+
*
|
|
4726
|
+
* movimentacoes/fluxos-gerais/:id/editar
|
|
4727
|
+
* => movimentacoes/fluxos-gerais
|
|
4728
|
+
*/
|
|
4729
|
+
const getPermissionRoute = (state) => {
|
|
4730
|
+
const routeSegments = [];
|
|
4731
|
+
let currentRoute = state.root;
|
|
4732
|
+
// console.log('currentRoute:', currentRoute);
|
|
4733
|
+
while (currentRoute) {
|
|
4734
|
+
const configuredPath = currentRoute.routeConfig?.path;
|
|
4735
|
+
// console.log('configuredPath:', configuredPath);
|
|
4736
|
+
if (configuredPath) {
|
|
4737
|
+
const configuredSegments = configuredPath.split('/');
|
|
4738
|
+
for (const segment of configuredSegments) {
|
|
4739
|
+
if (isRouteParameter(segment))
|
|
4740
|
+
return routeSegments.join('/');
|
|
4741
|
+
routeSegments.push(segment);
|
|
4742
|
+
}
|
|
4743
|
+
// console.log('routeSegments:', routeSegments);
|
|
4744
|
+
}
|
|
4745
|
+
currentRoute = getPrimaryChild(currentRoute);
|
|
4746
|
+
// console.log('currentRoute 2:', currentRoute);
|
|
4747
|
+
}
|
|
4748
|
+
return routeSegments.join('/');
|
|
4749
|
+
};
|
|
4750
|
+
/**
|
|
4751
|
+
* Identifica parâmetros declarados na configuração da rota.
|
|
4752
|
+
*
|
|
4753
|
+
* Exemplos:
|
|
4754
|
+
* :id
|
|
4755
|
+
* :codigo
|
|
4756
|
+
* :empresaId
|
|
4757
|
+
*/
|
|
4758
|
+
const isRouteParameter = (segment) => {
|
|
4759
|
+
return segment.startsWith(':');
|
|
4760
|
+
};
|
|
4761
|
+
/** Obtém a próxima rota ativa no outlet principal */
|
|
4762
|
+
const getPrimaryChild = (route) => {
|
|
4763
|
+
return route.children.find(child => child.outlet === PRIMARY_OUTLET);
|
|
4764
|
+
};
|
|
4765
|
+
|
|
4691
4766
|
/**
|
|
4692
4767
|
* Protege a página de login de ser carregada quando o usuário já está logado,
|
|
4693
4768
|
* redirecionando ele para a página home da aplicação.
|
|
@@ -5177,5 +5252,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImpo
|
|
|
5177
5252
|
* Generated bundle index. Do not edit.
|
|
5178
5253
|
*/
|
|
5179
5254
|
|
|
5180
|
-
export { AUTH_ROUTES, AuthAplicInterceptor, AuthGuard, AuthInfraInterceptor, AuthModule, AuthService, AuthStorageService, AuthUtilService, DynamicMenuComponent, ErrorMenuNotAllowed, ExternaLoginlGuard, FavoritarModel, IMenu, IndexedDBService, InfraEstabelecimentoFavoritoDefault, InfraUsuarioImg, IsMenuAllowedlGuard, LIB_CUSTOM_ENVIRONMENT_SERVICE, LIB_CUSTOM_LOGIN_SERVICE, LIB_CUSTOM_MENU_SERVICE, LIB_CUSTOM_STORAGE_SERVICE, LIB_MENU_CONFIG, LibCustomEnvironmentService, LibCustomLoginService, LibCustomMenuService, LibCustomStorageService, LibMenuConfigService, ListComponent, LoginComponent, LoginGuard, LoginOSComponent, LoginOSGuard, LoginProgress, MenuLateralComponent, MenuServicesService, MeuPerfilComponent, NavSubMenus, NavSubmenuCards, NavSubmenuSearchItem, NavTabsComponent, NotifSubmenuComponent, NovaSenhaComponent, PesquisaTelasGlobalService, PrimaryDropdownComponent, RetEstabelecimentosModal, RetInfraUsuarioImg, RetMenuItemStructure, RetMenuLateral, RetMenuPromise, RetNavSubMenu, RetSubmenuWithCards, SecondaryDropdownComponent, SelecaoEstabelecimentosModalComponent, SituacaoLogin, SubMenuCardComponent, SubMenuComponent, SubMenuItem, TelaItem };
|
|
5255
|
+
export { AUTH_ROUTES, AuthAplicInterceptor, AuthGuard, AuthInfraInterceptor, AuthModule, AuthService, AuthStorageService, AuthUtilService, DynamicMenuComponent, ErrorMenuNotAllowed, ExternaLoginlGuard, FavoritarModel, IMenu, IndexedDBService, InfraEstabelecimentoFavoritoDefault, InfraUsuarioImg, IsMenuAllowedGuard, IsMenuAllowedlGuard, LIB_CUSTOM_ENVIRONMENT_SERVICE, LIB_CUSTOM_LOGIN_SERVICE, LIB_CUSTOM_MENU_SERVICE, LIB_CUSTOM_STORAGE_SERVICE, LIB_MENU_CONFIG, LibCustomEnvironmentService, LibCustomLoginService, LibCustomMenuService, LibCustomStorageService, LibMenuConfigService, ListComponent, LoginComponent, LoginGuard, LoginOSComponent, LoginOSGuard, LoginProgress, MenuLateralComponent, MenuServicesService, MeuPerfilComponent, NavSubMenus, NavSubmenuCards, NavSubmenuSearchItem, NavTabsComponent, NotifSubmenuComponent, NovaSenhaComponent, PesquisaTelasGlobalService, PrimaryDropdownComponent, RetEstabelecimentosModal, RetInfraUsuarioImg, RetMenuItemStructure, RetMenuLateral, RetMenuPromise, RetNavSubMenu, RetSubmenuWithCards, SecondaryDropdownComponent, SelecaoEstabelecimentosModalComponent, SituacaoLogin, SubMenuCardComponent, SubMenuComponent, SubMenuItem, TelaItem };
|
|
5181
5256
|
//# sourceMappingURL=ngx-sp-auth.mjs.map
|