valtech-components 4.0.158 → 4.0.160

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.
@@ -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.160';
60
60
 
61
61
  // Control de estado de refresco (singleton a nivel de módulo)
62
62
  let isRefreshing = false;
@@ -33499,14 +33499,26 @@ 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
+ // Polling con setTimeout: sin maquinaria Angular (toObservable exige injection
33511
+ // context estable; los guards funcionales son contextos transitorios).
33512
+ while (authService.isLoading()) {
33513
+ await new Promise(r => setTimeout(r, 30));
33514
+ }
33506
33515
  if (!authService.isAuthenticated()) {
33507
33516
  return true;
33508
33517
  }
33509
- return router.createUrlTree([config.homeRoute]);
33518
+ // replaceUrl: true saca /login del stack del browser → el swipe-back en
33519
+ // PWA no vuelve a la pantalla de login.
33520
+ await router.navigateByUrl(config.homeRoute, { replaceUrl: true });
33521
+ return false;
33510
33522
  };
33511
33523
  /**
33512
33524
  * Factory para crear guard de permisos.
@@ -42973,7 +42985,7 @@ class LoginComponent {
42973
42985
  oauthProvider,
42974
42986
  });
42975
42987
  if (this.props.redirectOnSuccess) {
42976
- this.router.navigate([this.props.redirectOnSuccess]);
42988
+ void this.router.navigate([this.props.redirectOnSuccess], { replaceUrl: true });
42977
42989
  }
42978
42990
  }
42979
42991
  handleError(err, operation) {