ng-ipa-library 1.2.1 → 1.2.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.
- package/esm2020/lib/core/interceptors/myIPAToken.interceptor.mjs +4 -53
- package/fesm2015/ng-ipa-library.mjs +3 -51
- package/fesm2015/ng-ipa-library.mjs.map +1 -1
- package/fesm2020/ng-ipa-library.mjs +3 -50
- package/fesm2020/ng-ipa-library.mjs.map +1 -1
- package/lib/core/interceptors/myIPAToken.interceptor.d.ts +2 -8
- package/package.json +1 -1
|
@@ -1406,23 +1406,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImpor
|
|
|
1406
1406
|
}], ctorParameters: function () { return [{ type: AuthService }, { type: i2$4.HttpClient }, { type: LoaderService }]; } });
|
|
1407
1407
|
|
|
1408
1408
|
class myIPATokenInterceptor {
|
|
1409
|
-
constructor(authService
|
|
1409
|
+
constructor(authService) {
|
|
1410
1410
|
this.authService = authService;
|
|
1411
|
-
this.http = http;
|
|
1412
|
-
this.loaderService = loaderService;
|
|
1413
|
-
this.refresh = true;
|
|
1414
|
-
this.loaderService.addExceptionUrl({
|
|
1415
|
-
path: '/api/users?refresh',
|
|
1416
|
-
method: 'GET',
|
|
1417
|
-
});
|
|
1418
1411
|
}
|
|
1419
1412
|
intercept(request, next) {
|
|
1420
|
-
if (this.isException(request)) {
|
|
1421
|
-
return next.handle(request);
|
|
1422
|
-
}
|
|
1423
1413
|
const token = this.authService.getTokenFromHidden();
|
|
1424
1414
|
if (token) {
|
|
1425
|
-
this.isTokenExpired(token);
|
|
1426
1415
|
request = request.clone({
|
|
1427
1416
|
setHeaders: {
|
|
1428
1417
|
Authorization: `Bearer ${token}`,
|
|
@@ -1431,48 +1420,12 @@ class myIPATokenInterceptor {
|
|
|
1431
1420
|
}
|
|
1432
1421
|
return next.handle(request);
|
|
1433
1422
|
}
|
|
1434
|
-
isTokenExpired(token) {
|
|
1435
|
-
const redirectPath = location.pathname;
|
|
1436
|
-
const decodedToken = this.authService.getDecodedTokenFromHidden();
|
|
1437
|
-
const expDate = new Date((decodedToken.exp ?? 0) * 1000);
|
|
1438
|
-
if (expDate < new Date()) {
|
|
1439
|
-
location.replace('/ar/login?redirect=' + redirectPath);
|
|
1440
|
-
return;
|
|
1441
|
-
}
|
|
1442
|
-
else {
|
|
1443
|
-
if (this.authService.currentUserUrl) {
|
|
1444
|
-
if (this.refresh) {
|
|
1445
|
-
this.http
|
|
1446
|
-
.get(this.authService.currentUserUrl + `/api/users?refresh`, {
|
|
1447
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
1448
|
-
})
|
|
1449
|
-
.subscribe((user) => {
|
|
1450
|
-
localStorage.setItem('token', user.token);
|
|
1451
|
-
this.refresh = false;
|
|
1452
|
-
setTimeout(() => {
|
|
1453
|
-
this.refresh = true;
|
|
1454
|
-
}, 60 * 1000);
|
|
1455
|
-
});
|
|
1456
|
-
}
|
|
1457
|
-
}
|
|
1458
|
-
else {
|
|
1459
|
-
throw new Error("provide current base user api url using this function authService.setCurrentUserUrl('https://...')");
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
isException(request) {
|
|
1464
|
-
if (request.url.includes('/api/users?refresh') &&
|
|
1465
|
-
request.method === 'GET') {
|
|
1466
|
-
return true;
|
|
1467
|
-
}
|
|
1468
|
-
return false;
|
|
1469
|
-
}
|
|
1470
1423
|
}
|
|
1471
|
-
myIPATokenInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: myIPATokenInterceptor, deps: [{ token: AuthService }
|
|
1424
|
+
myIPATokenInterceptor.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: myIPATokenInterceptor, deps: [{ token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1472
1425
|
myIPATokenInterceptor.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: myIPATokenInterceptor });
|
|
1473
1426
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.2", ngImport: i0, type: myIPATokenInterceptor, decorators: [{
|
|
1474
1427
|
type: Injectable
|
|
1475
|
-
}], ctorParameters: function () { return [{ type: AuthService }
|
|
1428
|
+
}], ctorParameters: function () { return [{ type: AuthService }]; } });
|
|
1476
1429
|
|
|
1477
1430
|
class BreadcrumbsService {
|
|
1478
1431
|
constructor() { }
|