@propmix/profet-common-header 3.2.0-beta → 3.2.0

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.
@@ -405,7 +405,7 @@ class HeaderComponent {
405
405
  this._snackbar = inject(MatSnackBar);
406
406
  this._headerSer = inject(CommonHeaderService);
407
407
  this._domSanitizer = inject(DomSanitizer);
408
- this.INACTIVITY_LIMIT = 120000; // 2 minutes
408
+ this.INACTIVITY_LIMIT = 30 * 60 * 1000; // 30 minutes
409
409
  this.logoutEvent = new EventEmitter();
410
410
  this.companyControl = new FormControl();
411
411
  this.appConfig = AppConfig.appConfig;
@@ -522,11 +522,19 @@ class HeaderComponent {
522
522
  // Poll for the logout signal cookie (works across ports/subdomains)
523
523
  this.logoutCheckInterval = setInterval(() => {
524
524
  if (this.getCookie('session_expired')) {
525
- this.handleLogout(false);
525
+ // Check if tab still "active" according to the shared time
526
+ // If tab is active but receiving a logout signal, it implies a MANUAL logout from another tab.
527
+ // If tab is inactive and receiving a logout signal, it implies a TIMEOUT.
528
+ const lastActive = this.getCookie('lastActiveSessionTime');
529
+ const now = Date.now();
530
+ const lastActiveTime = lastActive ? parseInt(lastActive, 10) : 0;
531
+ const elapsed = now - lastActiveTime;
532
+ const isManual = elapsed < this.INACTIVITY_LIMIT;
533
+ this.handleLogout(false, false, isManual);
526
534
  }
527
535
  }, 2000); // Check every 2 seconds
528
536
  }
529
- handleLogout(broadcast = true, showPopup = true) {
537
+ handleLogout(broadcast = true, showPopup = true, isManual = false) {
530
538
  // Prevent multiple popups if already open
531
539
  // if (this._headerSer.isSessionExpiryDialogOpen && showPopup) {
532
540
  // return;
@@ -536,9 +544,13 @@ class HeaderComponent {
536
544
  this.setCookie('session_expired', 'true', 1);
537
545
  }
538
546
  this.logoutEvent.emit();
539
- let appUrl = this._headerSer.headerConfig.signOutUrl;
540
- let separator = appUrl.includes('?') ? '&' : '?';
541
- let sessionUrl = appUrl + separator + 'sessionExpired=true&timeout=' + this.INACTIVITY_LIMIT;
547
+ let sessionUrl = this._headerSer.headerConfig.signOutUrl;
548
+ // Only add sessionExpired params if it is NOT a manual logout
549
+ if (!isManual) {
550
+ let appUrl = this._headerSer.headerConfig.signOutUrl;
551
+ let separator = appUrl.includes('?') ? '&' : '?';
552
+ sessionUrl = appUrl + separator + 'sessionExpired=true&timeout=' + this.INACTIVITY_LIMIT;
553
+ }
542
554
  signOut({ global: true, oauth: { redirectUrl: sessionUrl } })
543
555
  .then(() => {
544
556
  window.open(sessionUrl, '_self');