@nauticana/sail 1.1.43 → 1.1.44

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nauticana/sail",
3
- "version": "1.1.43",
3
+ "version": "1.1.44",
4
4
  "description": "Metadata-driven Angular component library for CRUD admin frontends backed by the keel Go backend. Tables, forms, navigation, OTP/2FA/social auth, billing, payout onboarding.",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -82,6 +82,8 @@ export abstract class BaseAuthService extends BaseRestService {
82
82
  * so the login screen doesn't keep the previous user's route tree. */
83
83
  private preLoginRoutes: Routes | null = null;
84
84
  private landing: string | null = null;
85
+ // A signed-in page's own address, read before Angular's first navigation can send an unknown menu route to login.
86
+ private initialUrl = localStorage.getItem('jwt') ? window.location.pathname + window.location.search : null;
85
87
 
86
88
  // Lazy getters, not field initializers: fields would snapshot during super(),
87
89
  // before a subclass constructor can call configureRestUrls().
@@ -881,19 +883,17 @@ export abstract class BaseAuthService extends BaseRestService {
881
883
  }
882
884
 
883
885
  /**
884
- * Where to land after routes are (re)built. A fresh login starts from the
885
- * root or a `/login` route → go to the dashboard. A refresh / bookmark of an
886
- * authenticated route → preserve it so deep links survive route restoration.
886
+ * Where to land after routes are (re)built: a `setLanding()` URL, else the
887
+ * address the page loaded with (first build) or is on, unless that is the
888
+ * root or a `/login` route, which go to the dashboard.
887
889
  */
888
890
  private postLoginTarget(): string {
889
- if (this.landing) {
890
- const url = this.landing;
891
- this.landing = null;
892
- return url;
893
- }
894
- const path = window.location.pathname;
895
- const preserve = !!path && path !== '/' && !path.startsWith('/login');
896
- return preserve ? path + window.location.search : '/dashboard';
891
+ const landing = this.landing;
892
+ const url = this.initialUrl ?? window.location.pathname + window.location.search;
893
+ this.landing = this.initialUrl = null;
894
+ if (landing) return landing;
895
+ const path = url.split('?')[0];
896
+ return path !== '/' && !path.startsWith('/login') ? url : '/dashboard';
897
897
  }
898
898
 
899
899
  async initRoutes() {