@hotosm/hanko-auth 0.3.1 → 0.3.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.
@@ -4502,9 +4502,12 @@ let ge = class extends Ut {
4502
4502
  } catch (n) {
4503
4503
  this.logError("Hanko logout failed:", n);
4504
4504
  }
4505
- this._clearAuthState(), this.log(
4505
+ if (this._clearAuthState(), this.log(
4506
4506
  "✅ Logout complete - component will re-render with updated state"
4507
- ), this.redirectAfterLogout && (this.log("🔄 Redirecting after logout to:", this.redirectAfterLogout), window.location.href = this.redirectAfterLogout);
4507
+ ), this.redirectAfterLogout) {
4508
+ const n = window.location.href.replace(/\/$/, ""), e = this.redirectAfterLogout.replace(/\/$/, "");
4509
+ n !== e && !n.startsWith(e + "#") ? (this.log("🔄 Redirecting after logout to:", this.redirectAfterLogout), window.location.href = this.redirectAfterLogout) : this.log("⏭️ Already on logout target, skipping redirect");
4510
+ }
4508
4511
  }
4509
4512
  /**
4510
4513
  * Clear all auth state - shared between logout and session expired handlers
@@ -4542,10 +4545,13 @@ let ge = class extends Ut {
4542
4545
  } catch (n) {
4543
4546
  this.logError("❌ OSM disconnect failed:", n);
4544
4547
  }
4545
- this._clearAuthState(), this.log("✅ Session cleanup complete"), this.redirectAfterLogout && (this.log(
4546
- "🔄 Redirecting after session expired to:",
4547
- this.redirectAfterLogout
4548
- ), window.location.href = this.redirectAfterLogout);
4548
+ if (this._clearAuthState(), this.log("✅ Session cleanup complete"), this.redirectAfterLogout) {
4549
+ const n = window.location.href.replace(/\/$/, ""), e = this.redirectAfterLogout.replace(/\/$/, "");
4550
+ n !== e && !n.startsWith(e + "#") ? (this.log(
4551
+ "🔄 Redirecting after session expired to:",
4552
+ this.redirectAfterLogout
4553
+ ), window.location.href = this.redirectAfterLogout) : this.log("⏭️ Already on logout target, skipping redirect");
4554
+ }
4549
4555
  }
4550
4556
  handleUserLoggedOut() {
4551
4557
  this.log("🚪 User logged out in another window/tab"), this.handleSessionExpired();
@@ -4553,8 +4559,8 @@ let ge = class extends Ut {
4553
4559
  handleDropdownSelect(n) {
4554
4560
  const e = n.detail.item.value;
4555
4561
  if (this.log("🎯 Dropdown item selected:", e), e === "profile") {
4556
- const t = this.hankoUrl, o = this.redirectAfterLogin || window.location.origin;
4557
- window.location.href = `${t}/app/profile?return_to=${encodeURIComponent(o)}`;
4562
+ const t = this.loginUrl || this.hankoUrl, o = this.redirectAfterLogin || window.location.origin;
4563
+ window.location.href = `${t}/profile?return_to=${encodeURIComponent(o)}`;
4558
4564
  } else if (e === "connect-osm") {
4559
4565
  const i = window.location.pathname.includes("/app") ? window.location.origin : window.location.href, s = this.hankoUrl;
4560
4566
  window.location.href = `${s}/app?return_to=${encodeURIComponent(