ng-ipa-library 0.4.5 → 0.4.9

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.
@@ -1581,6 +1581,7 @@
1581
1581
  function TokenInterceptor(authService, http) {
1582
1582
  this.authService = authService;
1583
1583
  this.http = http;
1584
+ this.refresh = false;
1584
1585
  }
1585
1586
  TokenInterceptor.prototype.intercept = function (request, next) {
1586
1587
  if (this.isException(request)) {
@@ -1598,6 +1599,7 @@
1598
1599
  return next.handle(request);
1599
1600
  };
1600
1601
  TokenInterceptor.prototype.isTokenExpired = function (token) {
1602
+ var _this = this;
1601
1603
  var _a;
1602
1604
  var redirectPath = location.pathname;
1603
1605
  var decodedToken = this.authService.getDecodedToken();
@@ -1608,21 +1610,28 @@
1608
1610
  }
1609
1611
  else {
1610
1612
  if (this.authService.currentUserUrl) {
1611
- this.http
1612
- .get(this.authService.currentUserUrl + "/api/users", {
1613
- headers: { Authorization: "Bearer " + token },
1614
- })
1615
- .subscribe(function (user) {
1616
- localStorage.setItem('token', JSON.stringify(user.token));
1617
- });
1613
+ if (this.refresh) {
1614
+ this.http
1615
+ .get(this.authService.currentUserUrl + "/api/users?refresh", {
1616
+ headers: { Authorization: "Bearer " + token },
1617
+ })
1618
+ .subscribe(function (user) {
1619
+ localStorage.setItem('token', user.token);
1620
+ _this.refresh = false;
1621
+ setTimeout(function () {
1622
+ _this.refresh = true;
1623
+ }, 25000);
1624
+ });
1625
+ }
1618
1626
  }
1619
1627
  else {
1620
- throw new Error("provide current base user api url using this function authSerice.setCurrentUserUrl('https://...')");
1628
+ throw new Error("provide current base user api url using this function authService.setCurrentUserUrl('https://...')");
1621
1629
  }
1622
1630
  }
1623
1631
  };
1624
1632
  TokenInterceptor.prototype.isException = function (request) {
1625
- if (request.url.includes('/api/users') && request.method === 'GET') {
1633
+ if (request.url.includes('/api/users?refresh') &&
1634
+ request.method === 'GET') {
1626
1635
  return true;
1627
1636
  }
1628
1637
  return false;
@@ -1801,7 +1810,7 @@
1801
1810
  var scripts = this.getElementTag('script');
1802
1811
  var printContents = (_a = document.getElementById(element)) === null || _a === void 0 ? void 0 : _a.innerHTML;
1803
1812
  var popupWin = window.open('', '', 'top=0,left=0,height=100%,width=auto');
1804
- var data = "\n <!DOCTYPE html>\n <head>\n <title> " + title + " </title>\n <meta charset=\"utf-8\">\n " + linkes + "\n " + styles + "\n <style>\n @media print {\n body {\n direction: rtl;\n }\n }\n </style>\n </head>\n <body class=\"" + classes + "\">\n " + printContents + "\n " + scripts + "\n </body>\n\n </html>";
1813
+ var data = "\n <!DOCTYPE html>\n <head>\n <title> " + title + " </title>\n <meta charset=\"utf-8\">\n " + linkes + "\n " + styles + "\n <style>\n @media print {\n .noPrint{\n display: none !important;\n }\n body {\n direction: rtl;\n }\n }\n </style>\n </head>\n <body class=\"" + classes + "\">\n " + printContents + "\n " + scripts + "\n </body>\n\n </html>";
1805
1814
  popupWin === null || popupWin === void 0 ? void 0 : popupWin.document.open();
1806
1815
  popupWin === null || popupWin === void 0 ? void 0 : popupWin.document.write(data);
1807
1816
  popupWin === null || popupWin === void 0 ? void 0 : popupWin.document.close();