ngx-sp-auth 4.1.1 → 4.1.2

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.
@@ -1388,6 +1388,23 @@ class MenuServicesService {
1388
1388
  }));
1389
1389
  }
1390
1390
  // #endregion Menu: Version
1391
+ // #region Menu: IsMenuAllowed
1392
+ /** Método executado para validar a permissão de acesso a uma opção do menu
1393
+ */
1394
+ isMenuAllowed(route) {
1395
+ const params = new HttpParams()
1396
+ .set('route', route);
1397
+ const headers = new HttpHeaders().set("Content-Type", "application/json");
1398
+ const url = `${this._BASE_URL}/Menu/IsMenuAllowed`;
1399
+ return this._httpClient
1400
+ .get(url, { 'params': params, headers: headers })
1401
+ .pipe(take(1), tap((response) => {
1402
+ if (response.Error) {
1403
+ throw Error(response.ErrorMessage);
1404
+ }
1405
+ }));
1406
+ }
1407
+ // #endregion Menu: IsMenuAllowed
1391
1408
  // #endregion GET
1392
1409
  // #region UPDATE
1393
1410
  // #region Menu: Usuário
@@ -1908,7 +1925,7 @@ class LoginComponent {
1908
1925
  //Incialização de Senha
1909
1926
  if (response.InitializePassword) {
1910
1927
  let param = btoa(`true$${this.dominio}$${this.usuario}$${response.StatusSenha}`);
1911
- this._router.navigate([`auth/login/novaSenha/${param}`]);
1928
+ this._router.navigate([`auth/login/${param}`]);
1912
1929
  this._toastrService.success("Verifique no seu e-mail o código de validação.");
1913
1930
  }
1914
1931
  if (this._authStorageService.infraInAuthTypeId == InfraInAuthTypeId.Local && this._authStorageService.infraIn2FaTypeId != null && this._authStorageService.infraIn2FaTypeId == InfraIn2FaTypeId.Email && this._authStorageService.is2FaEnabled) {
@@ -1954,7 +1971,7 @@ class LoginComponent {
1954
1971
  //Incialização de Senha
1955
1972
  if (response.InitializePassword) {
1956
1973
  let param = btoa(`true$${this.dominio}$${this.usuarioAzure}$${response.StatusSenha}`);
1957
- this._router.navigate([`auth/login/novaSenha/${param}`]);
1974
+ this._router.navigate([`auth/login/${param}`]);
1958
1975
  this._toastrService.success("Verifique no seu e-mail o código de validação.");
1959
1976
  }
1960
1977
  if (this._authStorageService.infraInAuthTypeId == InfraInAuthTypeId.Local && this._authStorageService.infraIn2FaTypeId != null && this._authStorageService.infraIn2FaTypeId == InfraIn2FaTypeId.Email && this._authStorageService.is2FaEnabled) {
@@ -3311,6 +3328,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
3311
3328
  ], preserveWhitespaces: true, template: "<body>\n<div id=\"main-container\">\n\t<!-- #region MAIN CONTENT -->\n\t<div class=\"glb-main-container password-container\">\n\t\t<div class=\"password-info-container\">\n\t\t\t<div class=\"img mb-3\">\n\t\t\t\t<img [src]=\"statusSenha == 2 ? calendarioImg : statusSenha == 1 ? maoImg : statusSenha == 3 ? cadeadoImg : '' \" width=\"125.69\" height=\"122\">\n\t\t\t</div>\n\t\t\t<div class=\"text\">\n\t\t\t\t<h4>{{statusSenha == 2 ? 'Senha expirada' : statusSenha == 1 ? 'Primeiro acesso' : statusSenha == 3 ? 'Esqueceu sua senha?' : ''}}</h4>\n\t\t\t\t<p [innerHTML]=\"statusSenha == 2 ? senhaExpiradaText : statusSenha == 1 ? primeiroAcessoText : statusSenha == 3 ? esqueceuSenhaText : '' \"></p>\n\t\t\t</div>\n\t\t</div>\n\t\t<form [formGroup]=\"form\">\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-12 mb-3\">\n\t\t\t\t\t<label for=\"inputCode\" class=\"form-label\"> C\u00F3digo de valida\u00E7\u00E3o <span class=\"text-danger\">*</span></label>\n\t\t\t\t\t<input type=\"text\" placeholder=\"Insira seu c\u00F3digo aqui...\" id=\"inputCode\" class=\"form-control\" formControlName=\"code\"\n\t\t\t\t\t\t[class.is-invalid]=\"FormUtils.isInvalidField(form.get('code'))\">\n\t\t\t\t\t<app-field-error-message [control]=\"form.get('code')\" label=\"C\u00F3digo de valida\u00E7\u00E3o\"></app-field-error-message>\t\t\t\t\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-12 mb-3\">\n\t\t\t\t\t<label for=\"inputPassword\" class=\"form-label\"> Digite uma nova Senha <span class=\"text-danger\">*</span></label>\n\t\t\t\t\t<input type=\"password\" placeholder=\"Digite sua nova senha...\" id=\"inputPassword\" class=\"form-control\" formControlName=\"password\"\n\t\t\t\t\t\t[class.is-invalid]=\"FormUtils.isInvalidField(form.get('password'))\">\n\t\t\t\t\t<app-field-error-message [control]=\"form.get('password')\" label=\"{{ passwordLabel }}\"></app-field-error-message>\t\t\t\t\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t\n\t\t\t<div class=\"row\">\n\t\t\t\t<div class=\"col-12 mb-3\">\n\t\t\t\t\t<label for=\"inputConfirmPassword\" class=\"form-label\"> Confirme sua nova Senha <span class=\"text-danger\">*</span></label>\n\t\t\t\t\t<input type=\"password\" placeholder=\"Digite a senha novamente...\" id=\"inputConfirmPassword\" class=\"form-control\" formControlName=\"confirmPassword\"\n\t\t\t\t\t\t[class.is-invalid]=\"FormUtils.isInvalidField(form.get('confirmPassword'))\">\n\t\t\t\t\t<app-field-error-message [control]=\"form.get('confirmPassword')\" label=\"Confirme sua Senha\"></app-field-error-message>\t\t\t\t\n\t\t\t\t</div>\n\t\t\t</div>\n\n\t\t\t\t<div class=\"btns\">\n\t\t\t\t\t<button [libLoading]=\"isLoading\" loadingText=\"Redefinindo...\" [disabled]=\"isLoading\" (click)=\"sendPassword()\" type=\"button\" class=\"btn btn-primary col w-100\">\n\t\t\t\t\t\tRedefinir senha <lib-icon iconName=\"login\" />\n\t\t\t\t\t</button>\n\n\t\t\t\t\t<div class=\"mt-3 text-center\">\n\t\t\t\t\t\t<a type=\"button\" class=\"fw-bold text-decoration-none text-secondary\" (click)=\"cancelar()\">\n\t\t\t\t\t\t\t<lib-icon iconName=\"p-seta-esquerda\" /> Voltar para a tela de login </a>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t</form>\n\t</div>\n\t<!-- #endregion MAIN CONTENT -->\n</div>\n</body>\n", styles: ["body{background-color:#f5f5f5;height:100%!important;margin:0!important;padding:0!important}#main-container{display:flex;align-items:center;justify-content:center;height:100%}.password-container{padding:30px;width:37%;border:none;box-shadow:0 2px -1px #0000001a}.img{width:26%}.text{display:flex;flex-direction:column;align-items:flex-start;margin-left:auto}.text h4{font-weight:700}.text p{text-align:start}.password-info-container{display:flex;gap:15px}.btns{display:flex;flex-direction:column;align-items:center;width:100%}input::placeholder{color:#8d8d8d;font-size:15px}.icon{margin-right:5px;font-weight:700}\n"] }]
3312
3329
  }], ctorParameters: () => [{ type: i3$1.FormBuilder }, { type: ProjectUtilservice }, { type: i3.MessageService }, { type: AuthService }, { type: AuthStorageService }, { type: i8.Title }, { type: i1$1.Router }, { type: i1$1.ActivatedRoute }] });
3313
3330
 
3331
+ class ErrorMenuNotAllowed {
3332
+ constructor(router, authStorageService) {
3333
+ this.router = router;
3334
+ this.authStorageService = authStorageService;
3335
+ }
3336
+ onHome() {
3337
+ this.router.navigate(["/home"]);
3338
+ }
3339
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ErrorMenuNotAllowed, deps: [{ token: i1$1.Router }, { token: AuthStorageService }], target: i0.ɵɵFactoryTarget.Component }); }
3340
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: ErrorMenuNotAllowed, isStandalone: true, selector: "app-menu-not-allowed", ngImport: i0, template: " <div class=\"content\">\n <div class=\"image mb-4\">\n <lib-icon iconName=\"cadeado\" [iconSize]=\"128\" />\n </div>\n <h1 class=\"tittle\">Voc\u00EA n\u00E3o possui permiss\u00E3o para acessar esta tela!</h1>\n <button *ngIf=\"!this.authStorageService.isExternalLogin\" class=\"btn button mt-3\" (click)=\"onHome()\">\n Voltar para a tela inicial\n </button>\n </div>\n", styles: [".content{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100vw;height:100vh}.image{text-align:center;display:block}.tittle{font-family:Open Sans;font-style:normal;font-weight:700;font-size:48px;line-height:65px;text-align:center;color:#212529}.sub-tittle{font-family:Open Sans;font-style:normal;font-weight:400;font-size:16px;line-height:22px;width:600px;text-align:center;color:#212529}.button{background:#0d6efd;border-radius:4px;font-family:Open Sans;font-style:normal;font-weight:400;font-size:16px;line-height:22px;color:#fff}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: InfraModule }, { kind: "component", type: i3.LibIconsComponent, selector: "lib-icon", inputs: ["iconName", "iconColor", "iconSize", "iconFill"] }], preserveWhitespaces: true }); }
3341
+ }
3342
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: ErrorMenuNotAllowed, decorators: [{
3343
+ type: Component,
3344
+ args: [{ selector: 'app-menu-not-allowed', preserveWhitespaces: true, imports: [
3345
+ NgIf,
3346
+ InfraModule
3347
+ ], template: " <div class=\"content\">\n <div class=\"image mb-4\">\n <lib-icon iconName=\"cadeado\" [iconSize]=\"128\" />\n </div>\n <h1 class=\"tittle\">Voc\u00EA n\u00E3o possui permiss\u00E3o para acessar esta tela!</h1>\n <button *ngIf=\"!this.authStorageService.isExternalLogin\" class=\"btn button mt-3\" (click)=\"onHome()\">\n Voltar para a tela inicial\n </button>\n </div>\n", styles: [".content{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100vw;height:100vh}.image{text-align:center;display:block}.tittle{font-family:Open Sans;font-style:normal;font-weight:700;font-size:48px;line-height:65px;text-align:center;color:#212529}.sub-tittle{font-family:Open Sans;font-style:normal;font-weight:400;font-size:16px;line-height:22px;width:600px;text-align:center;color:#212529}.button{background:#0d6efd;border-radius:4px;font-family:Open Sans;font-style:normal;font-weight:400;font-size:16px;line-height:22px;color:#fff}\n"] }]
3348
+ }], ctorParameters: () => [{ type: i1$1.Router }, { type: AuthStorageService }] });
3349
+
3314
3350
  class IMenu {
3315
3351
  constructor() {
3316
3352
  this.ID = 0;
@@ -3554,6 +3590,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
3554
3590
  }], ctorParameters: () => [{ type: i1$1.Router }, { type: AuthService }] });
3555
3591
  ;
3556
3592
 
3593
+ class IsMenuAllowedlGuard {
3594
+ constructor(router, _menuService) {
3595
+ this.router = router;
3596
+ this._menuService = _menuService;
3597
+ }
3598
+ canActivate(_route, _state) {
3599
+ let route = _route.routeConfig?.path === undefined ? "" : _route.routeConfig?.path;
3600
+ return this.isMenuAllowedGuard(route);
3601
+ }
3602
+ navigateToError() {
3603
+ let notAllowed = this.router.parseUrl("/error-menu-not-allowed");
3604
+ return notAllowed;
3605
+ }
3606
+ // Valida a permissão do Menu
3607
+ async isMenuAllowedGuard(route) {
3608
+ const menuAllowed = await this.handleIsMenuAllowed(route);
3609
+ if (!menuAllowed) {
3610
+ return this.navigateToError();
3611
+ }
3612
+ return menuAllowed;
3613
+ }
3614
+ // Handle para ver se o menu é permitido.
3615
+ async handleIsMenuAllowed(route) {
3616
+ try {
3617
+ let response = false;
3618
+ await this.IsMenuAllowed(route)
3619
+ .then(res => {
3620
+ response = res;
3621
+ return response;
3622
+ })
3623
+ .catch(err => {
3624
+ throw new Error(err);
3625
+ });
3626
+ return response;
3627
+ }
3628
+ catch (error) {
3629
+ return false;
3630
+ }
3631
+ }
3632
+ // Retorna se o menu é permitido.
3633
+ IsMenuAllowed(route) {
3634
+ return new Promise((resolve, reject) => {
3635
+ this._menuService.isMenuAllowed(route).subscribe({
3636
+ next: response => {
3637
+ resolve(response.IsMenuAllowed);
3638
+ },
3639
+ error: error => {
3640
+ reject(error);
3641
+ }
3642
+ });
3643
+ });
3644
+ }
3645
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IsMenuAllowedlGuard, deps: [{ token: i1$1.Router }, { token: MenuServicesService }], target: i0.ɵɵFactoryTarget.Injectable }); }
3646
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IsMenuAllowedlGuard, providedIn: 'root' }); }
3647
+ }
3648
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IsMenuAllowedlGuard, decorators: [{
3649
+ type: Injectable,
3650
+ args: [{ providedIn: 'root' }]
3651
+ }], ctorParameters: () => [{ type: i1$1.Router }, { type: MenuServicesService }] });
3652
+
3557
3653
  /**
3558
3654
  * \brief Intercepta uma chamada HTTP para inserir o usuário logado no header em conjunto
3559
3655
  * com o login para uso da API.
@@ -3855,5 +3951,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImpo
3855
3951
  * Generated bundle index. Do not edit.
3856
3952
  */
3857
3953
 
3858
- export { AUTH_ROUTES, AuthAplicInterceptor, AuthGuard, AuthInfraInterceptor, AuthModule, AuthService, AuthStorageService, DynamicMenuComponent, ExternaLoginlGuard, IMenu, InfraUsuarioImg, 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, NavSubMenus, NavSubmenuCards, NavSubmenuSearchItem, NavTabsComponent, NotifSubmenuComponent, NovaSenhaComponent, PrimaryDropdownComponent, RetInfraUsuarioImg, RetMenuItemStructure, RetMenuLateral, RetMenuPromise, RetNavSubMenu, RetSubmenuWithCards, SecondaryDropdownComponent, SelecaoEstabelecimentosModalComponent, SituacaoLogin, SubMenuCardComponent, SubMenuComponent, SubMenuItem, TelaItem };
3954
+ export { AUTH_ROUTES, AuthAplicInterceptor, AuthGuard, AuthInfraInterceptor, AuthModule, AuthService, AuthStorageService, DynamicMenuComponent, ErrorMenuNotAllowed, ExternaLoginlGuard, IMenu, 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, NavSubMenus, NavSubmenuCards, NavSubmenuSearchItem, NavTabsComponent, NotifSubmenuComponent, NovaSenhaComponent, PrimaryDropdownComponent, RetInfraUsuarioImg, RetMenuItemStructure, RetMenuLateral, RetMenuPromise, RetNavSubMenu, RetSubmenuWithCards, SecondaryDropdownComponent, SelecaoEstabelecimentosModalComponent, SituacaoLogin, SubMenuCardComponent, SubMenuComponent, SubMenuItem, TelaItem };
3859
3955
  //# sourceMappingURL=ngx-sp-auth.mjs.map