@dsivd/prestations-ng 15.2.3-beta4 → 15.2.3-beta7
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/dsivd-prestations-ng-v15.2.3-beta7.tgz +0 -0
- package/esm2020/sdk-redirect/iam-expired-interceptor.service.mjs +28 -14
- package/esm2020/sdk-redirect/redirect.component.mjs +2 -2
- package/fesm2015/dsivd-prestations-ng.mjs +26 -12
- package/fesm2015/dsivd-prestations-ng.mjs.map +1 -1
- package/fesm2020/dsivd-prestations-ng.mjs +26 -12
- package/fesm2020/dsivd-prestations-ng.mjs.map +1 -1
- package/package.json +1 -1
- package/sdk-redirect/iam-expired-interceptor.service.d.ts +2 -2
- package/dsivd-prestations-ng-v15.2.3-beta4.tgz +0 -0
|
@@ -31,32 +31,46 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
|
31
31
|
|
|
32
32
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
33
33
|
const IAM_SESSION_EXPIRED_HEADER = 'iam-session-expired';
|
|
34
|
-
const
|
|
34
|
+
const CYBER_LOGIN_PATH = '/100018/login';
|
|
35
|
+
const ACV_LOGIN_PATH = '/iamlogin';
|
|
36
|
+
const isIamExpiredHeader = (event) => !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
|
|
37
|
+
const isRedirectionToIamACV = (event) => {
|
|
38
|
+
const isRedirection = event.status === 302 /* Found */;
|
|
39
|
+
const location = event.headers.get('Location');
|
|
40
|
+
return isRedirection && location?.includes(ACV_LOGIN_PATH);
|
|
41
|
+
};
|
|
42
|
+
const isRedirectionToCyberLogin = (event) => {
|
|
43
|
+
const isRedirection = event.status === 302 /* Found */;
|
|
44
|
+
const location = event.headers.get('Location');
|
|
45
|
+
return isRedirection && location?.includes(CYBER_LOGIN_PATH);
|
|
46
|
+
};
|
|
35
47
|
class IamExpiredInterceptorService {
|
|
36
48
|
constructor() {
|
|
37
|
-
this.
|
|
49
|
+
this._isIamSessionExpired = new Subject();
|
|
38
50
|
}
|
|
39
|
-
get
|
|
40
|
-
return this.
|
|
51
|
+
get isIamSessionExpired() {
|
|
52
|
+
return this._isIamSessionExpired.asObservable();
|
|
41
53
|
}
|
|
42
54
|
intercept(req, next) {
|
|
43
55
|
return next.handle(req).pipe(map(event => {
|
|
56
|
+
console.log('event', typeof event, event);
|
|
44
57
|
if (event instanceof HttpResponse) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.
|
|
58
|
+
if (isIamExpiredHeader(event) ||
|
|
59
|
+
isRedirectionToIamACV(event) ||
|
|
60
|
+
isRedirectionToCyberLogin(event)) {
|
|
61
|
+
this._isIamSessionExpired.next(true);
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
return event;
|
|
52
65
|
}), catchError(this.handleError.bind(this)));
|
|
53
66
|
}
|
|
54
67
|
handleError(err) {
|
|
68
|
+
console.log('err', typeof err, err);
|
|
55
69
|
if (err instanceof HttpErrorResponse) {
|
|
56
|
-
if (err.status === 200) {
|
|
57
|
-
const isLogin = err.url.indexOf(
|
|
70
|
+
if (err.status === 200 /* Ok */) {
|
|
71
|
+
const isLogin = err.url.indexOf(CYBER_LOGIN_PATH) > 0;
|
|
58
72
|
if (isLogin) {
|
|
59
|
-
this.
|
|
73
|
+
this._isIamSessionExpired.next(true);
|
|
60
74
|
}
|
|
61
75
|
}
|
|
62
76
|
}
|
|
@@ -9922,7 +9936,7 @@ class RedirectComponent {
|
|
|
9922
9936
|
this.modalHeaderText = 'Information';
|
|
9923
9937
|
this.modalBodyText = `<p>Votre session a expiré.</p>
|
|
9924
9938
|
<p>Vous pouvez vous connecter à nouveau pour continuer à utiliser nos services.</p>`;
|
|
9925
|
-
this.iamInterceptor.
|
|
9939
|
+
this.iamInterceptor.isIamSessionExpired
|
|
9926
9940
|
.pipe(first())
|
|
9927
9941
|
.subscribe(() => this.showModal());
|
|
9928
9942
|
}
|