valtech-components 4.0.158 → 4.0.159

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.
@@ -15,7 +15,7 @@ import { provideAuth, getAuth, connectAuthEmulator, authState, signInWithCustomT
15
15
  import { provideMessaging, getMessaging, getToken, deleteToken, onMessage } from '@angular/fire/messaging';
16
16
  import * as i1$2 from '@angular/fire/storage';
17
17
  import { provideStorage, getStorage, connectStorageEmulator, ref, uploadBytesResumable, getDownloadURL, getMetadata, deleteObject, listAll } from '@angular/fire/storage';
18
- import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
18
+ import { takeUntilDestroyed, toObservable, toSignal } from '@angular/core/rxjs-interop';
19
19
  import * as i1$4 from '@angular/router';
20
20
  import { Router, NavigationEnd, RouterLink, ActivatedRoute, RouterOutlet, RouterModule } from '@angular/router';
21
21
  import * as i2 from '@ionic/angular';
@@ -56,7 +56,7 @@ import { BrowserMultiFormatReader } from '@zxing/browser';
56
56
  * Current version of valtech-components.
57
57
  * This is automatically updated during the publish process.
58
58
  */
59
- const VERSION = '4.0.158';
59
+ const VERSION = '4.0.159';
60
60
 
61
61
  // Control de estado de refresco (singleton a nivel de módulo)
62
62
  let isRefreshing = false;
@@ -33499,14 +33499,24 @@ const authGuard = (_route, state) => {
33499
33499
  * ];
33500
33500
  * ```
33501
33501
  */
33502
- const guestGuard = () => {
33502
+ const guestGuard = async () => {
33503
33503
  const authService = inject(AuthService);
33504
33504
  const router = inject(Router);
33505
33505
  const config = inject(VALTECH_AUTH_CONFIG);
33506
+ // Esperar a que la inicializacion de auth termine (Firebase restaura sesion
33507
+ // de forma async). Sin esto, `isAuthenticated()` puede ser false aunque el
33508
+ // token en localStorage sea valido, y el guard deja pasar al login → pantalla
33509
+ // de login con botones cargando (especialmente en swipe-back en PWA).
33510
+ if (authService.isLoading()) {
33511
+ await firstValueFrom(toObservable(authService.isLoading).pipe(filter$1(loading => !loading)));
33512
+ }
33506
33513
  if (!authService.isAuthenticated()) {
33507
33514
  return true;
33508
33515
  }
33509
- return router.createUrlTree([config.homeRoute]);
33516
+ // replaceUrl: true saca /login del stack del browser → el swipe-back en
33517
+ // PWA no vuelve a la pantalla de login.
33518
+ await router.navigateByUrl(config.homeRoute, { replaceUrl: true });
33519
+ return false;
33510
33520
  };
33511
33521
  /**
33512
33522
  * Factory para crear guard de permisos.
@@ -42973,7 +42983,7 @@ class LoginComponent {
42973
42983
  oauthProvider,
42974
42984
  });
42975
42985
  if (this.props.redirectOnSuccess) {
42976
- this.router.navigate([this.props.redirectOnSuccess]);
42986
+ void this.router.navigate([this.props.redirectOnSuccess], { replaceUrl: true });
42977
42987
  }
42978
42988
  }
42979
42989
  handleError(err, operation) {