ngx-sp-auth 4.23.5 → 4.23.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.
@@ -8,16 +8,17 @@ import { LogLevel, PublicClientApplication, InteractionType } from '@azure/msal-
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
10
  import { RouterLink, NavigationEnd, RouterOutlet } from '@angular/router';
11
- import { BehaviorSubject, map, catchError, of, finalize, shareReplay, defer, take, tap, firstValueFrom, Subject, Subscription, debounceTime, distinctUntilChanged, filter, switchMap, timer, lastValueFrom, from, throwError } from 'rxjs';
12
11
  import * as i3 from 'ngx-sp-infra';
13
- import { IpServiceService, GlobalLoadingService, Utils, SearchInputComponent, InfraModule, FormUtils, Usuario, RetPasswordPolicy, RetCheckPassword, CheckPasswordRecord, PasswordPolicyComponent, LibIconsComponent, ContentContainerComponent } from 'ngx-sp-infra';
12
+ import { IpServiceService, Utils, SearchInputComponent, InfraModule, FormUtils, Usuario, RetPasswordPolicy, RetCheckPassword, CheckPasswordRecord, PasswordPolicyComponent, LibIconsComponent, ContentContainerComponent } from 'ngx-sp-infra';
13
+ import * as i10 from 'ngx-toastr';
14
+ import { ToastrService } from 'ngx-toastr';
15
+ import { BehaviorSubject, map, catchError, of, finalize, shareReplay, defer, take, tap, firstValueFrom, Subject, Subscription, debounceTime, distinctUntilChanged, filter, switchMap, timer, lastValueFrom, from, throwError } from 'rxjs';
14
16
  import { openDB, deleteDB } from 'idb';
15
17
  import * as i17 from '@angular/common';
16
18
  import { NgIf, CommonModule, NgClass } from '@angular/common';
17
19
  import * as i7 from '@angular/forms';
18
20
  import { Validators, ReactiveFormsModule, FormGroup, FormControl, FormsModule } from '@angular/forms';
19
21
  import * as i8 from '@angular/platform-browser';
20
- import * as i10 from 'ngx-toastr';
21
22
  import * as i11 from '@angular/cdk/layout';
22
23
  import { Breakpoints } from '@angular/cdk/layout';
23
24
  import * as i15 from 'ngx-bootstrap/popover';
@@ -522,7 +523,7 @@ class AuthStorageService {
522
523
  this._customEnvironmentService = _customEnvironmentService;
523
524
  this._router = _router;
524
525
  this._ipService = inject(IpServiceService);
525
- this._globalLoadingService = inject(GlobalLoadingService);
526
+ this._toastr = inject(ToastrService);
526
527
  this._BASE_URL = ''; // SpInfra2LoginWS
527
528
  this._LOGOUT_BASE_URL = ''; // SpInfra2LoginWS
528
529
  this._BASE_VERIFICATION_URL = ''; // SpInfra2LoginWS
@@ -831,7 +832,7 @@ class AuthStorageService {
831
832
  const url = `${this._BASE_VERIFICATION_URL}`;
832
833
  const headers = this._HTTP_HEADERS;
833
834
  return defer(() => {
834
- this._globalLoadingService.show(false, 'Validando token do usuário.');
835
+ this._toastr.info('Validando token do usuário.', 'Aguarde...', { timeOut: 3000, progressBar: true, progressAnimation: 'increasing', closeButton: true });
835
836
  const params = new HttpParams()
836
837
  .set('ip', this.ip)
837
838
  .set('browser', this._ipService.getDataBrowserUser().browser);
@@ -842,7 +843,9 @@ class AuthStorageService {
842
843
  else
843
844
  this.isLoggedInSub.next(true);
844
845
  }));
845
- }).pipe(finalize(() => this._globalLoadingService.hide()));
846
+ }).pipe(finalize(() => {
847
+ this._toastr.clear();
848
+ }));
846
849
  }
847
850
  /** Verifica a cada diferença de tempo entre a data atual e a data do token. */
848
851
  // public async reCheckLogin(renew: boolean) {
@@ -4701,7 +4704,7 @@ class LoginGuard {
4701
4704
  * @param route Rota atual
4702
4705
  * @param segments Segmentos.
4703
4706
  * @returns
4704
- */
4707
+ */
4705
4708
  canLoad(_route, _segments) {
4706
4709
  return this.authStorageService.checkAuthentication()
4707
4710
  .pipe(map(() => {
@@ -4711,6 +4714,15 @@ class LoginGuard {
4711
4714
  return true;
4712
4715
  }));
4713
4716
  }
4717
+ canMatch(_route, segments) {
4718
+ return this.authStorageService.checkAuthentication()
4719
+ .pipe(map(() => {
4720
+ if ((_route.path === "auth/login" && this.authStorageService.isLoggedInSub.value && !this.authStorageService.isExternalLogin)) {
4721
+ return this.router.createUrlTree(["/home"]);
4722
+ }
4723
+ return true;
4724
+ }));
4725
+ }
4714
4726
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LoginGuard, deps: [{ token: i1$1.Router }, { token: AuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4715
4727
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: LoginGuard, providedIn: 'root' }); }
4716
4728
  }