@stemy/ngx-utils 11.1.1 → 11.2.3

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.
@@ -1923,7 +1923,20 @@ class AclService {
1923
1923
  const check = info && info.guard instanceof AuthGuard ? info.guard.checkRoute(info.route) : Promise.resolve(true);
1924
1924
  check.then(result => {
1925
1925
  if (result) {
1926
- AclService.checkStateDirty(info);
1926
+ if (!info || !info.dirty)
1927
+ return;
1928
+ info.dirty = false;
1929
+ const component = info.component;
1930
+ if (info.first) {
1931
+ if (ObjectUtils.isFunction(component.onUserInitialized)) {
1932
+ component.onUserInitialized();
1933
+ }
1934
+ info.first = false;
1935
+ return;
1936
+ }
1937
+ if (ObjectUtils.isFunction(component.onUserChanged)) {
1938
+ component.onUserChanged();
1939
+ }
1927
1940
  return;
1928
1941
  }
1929
1942
  info.guard.getReturnState(info.route).then(returnState => {
@@ -1935,24 +1948,13 @@ class AclService {
1935
1948
  });
1936
1949
  this.state.subscribe(() => {
1937
1950
  const info = this.getStateInfo();
1938
- AclService.checkStateDirty(info);
1939
- });
1940
- }
1941
- static checkStateDirty(info) {
1942
- if (!info || !info.dirty)
1943
- return;
1944
- info.dirty = false;
1945
- const component = info.component;
1946
- if (info.first) {
1951
+ if (!(info === null || info === void 0 ? void 0 : info.component))
1952
+ return;
1953
+ const component = info.component;
1947
1954
  if (ObjectUtils.isFunction(component.onUserInitialized)) {
1948
1955
  component.onUserInitialized();
1949
1956
  }
1950
- info.first = false;
1951
- return;
1952
- }
1953
- if (ObjectUtils.isFunction(component.onUserChanged)) {
1954
- component.onUserChanged();
1955
- }
1957
+ });
1956
1958
  }
1957
1959
  getStateInfo() {
1958
1960
  const route = this.state.route;
@@ -1963,13 +1965,13 @@ class AclService {
1963
1965
  const guardType = (route.canActivate || emptyGuards)[0];
1964
1966
  info = {
1965
1967
  route: this.state.route,
1966
- component: this.state.component,
1967
1968
  guard: guardType ? this.injector.get(guardType) : null,
1968
- dirty: false,
1969
+ dirty: true,
1969
1970
  first: true
1970
1971
  };
1971
1972
  this.components.push(info);
1972
1973
  }
1974
+ info.component = this.state.component;
1973
1975
  return info;
1974
1976
  }
1975
1977
  }
@@ -2262,11 +2264,12 @@ class BaseHttpService {
2262
2264
  const authKey = "Authorization";
2263
2265
  // If an authorization header exists and we still have an Unauthorized response prompt the user to log in again
2264
2266
  if (headers.has(authKey) && response.status == 401) {
2265
- this.pushFailedRequest(url, options, () => {
2267
+ const pushed = this.pushFailedRequest(url, options, () => {
2266
2268
  options.headers = this.makeHeaders(options.originalHeaders);
2267
2269
  this.toPromise(url, options, listener).then(resolve, reject);
2268
2270
  });
2269
- this.handleUnauthorizedError(absoluteUrl, options, () => reject(response));
2271
+ if (pushed)
2272
+ this.handleUnauthorizedError(absoluteUrl, options, () => reject(response));
2270
2273
  return;
2271
2274
  }
2272
2275
  reject(response);
@@ -2276,8 +2279,9 @@ class BaseHttpService {
2276
2279
  }
2277
2280
  pushFailedRequest(url, options, req) {
2278
2281
  if (url.indexOf("tokens") >= 0)
2279
- return;
2282
+ return false;
2280
2283
  BaseHttpService.failedRequests.push(req);
2284
+ return true;
2281
2285
  }
2282
2286
  checkHeaders(headers) {
2283
2287
  if (!headers || !headers.cookie || !headers.referer || !headers.host) {
@@ -2411,6 +2415,14 @@ class ConfigService {
2411
2415
  }
2412
2416
  this.baseConfig = baseConfig || {};
2413
2417
  this.loadedConfig = Object.assign(!baseUrl ? {} : { baseUrl }, this.baseConfig);
2418
+ try {
2419
+ const url = new URL(this.loadedConfig.baseUrl);
2420
+ const port = url.port && url.port !== "443" && url.port !== "80" ? `:${url.port}` : ``;
2421
+ this.loadedConfig.baseDomain = `${url.protocol}://${url.hostname}${port}/`;
2422
+ }
2423
+ catch (_a) {
2424
+ this.loadedConfig.baseDomain = "/";
2425
+ }
2414
2426
  this.scriptParameters = scriptParams || {};
2415
2427
  this.loaderFunc = () => {
2416
2428
  this.loader = this.loader || new Promise((resolve, reject) => {
@@ -2458,7 +2470,8 @@ class ConfigService {
2458
2470
  const project = !this.loadedConfig ? "" : this.loadedConfig.project;
2459
2471
  url = url ? `${url.replace(/\/+$/, "")}${ending}` : ending;
2460
2472
  url = url.replace("[project]", project);
2461
- return this.universal.isServer && url.startsWith("//") ? `http:${url}` : url;
2473
+ url = this.universal.isServer && url.startsWith("//") ? `http:${url}` : url;
2474
+ return url.startsWith("/") ? this.loadedConfig.baseUrl + url.substr(1) : url;
2462
2475
  }
2463
2476
  getConfigValue(key) {
2464
2477
  return this.loadedConfig[key];