@dsivd/prestations-ng 15.2.3-beta5 → 15.2.3-beta8

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.
@@ -32,35 +32,30 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
32
32
  /* eslint-disable @typescript-eslint/no-explicit-any */
33
33
  const IAM_SESSION_EXPIRED_HEADER = 'iam-session-expired';
34
34
  const CYBER_LOGIN_PATH = '/100018/login';
35
- const PORTAIL_IAM_ACV_EXTRA_PATH = 'portail.vd.ch:443/iamlogin';
36
- const PORTAIL_IAM_ACV_INTRA_PATH = 'portail.etat-de-vaud.ch:443/iamlogin';
37
- const isIamExpiredHeader = (event) => !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
38
- const isRedirectionToIamACV = (event) => {
39
- const isRedirection = event.status === 302 /* Found */;
40
- const location = event.headers.get('Location');
41
- return (isRedirection &&
42
- (location?.includes(PORTAIL_IAM_ACV_EXTRA_PATH) ||
43
- location?.includes(PORTAIL_IAM_ACV_INTRA_PATH)));
35
+ const ACV_LOGIN_PATH = '/iamlogin';
36
+ const isIamExpiredHeader = (event) => {
37
+ return !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
44
38
  };
45
- const isRedirectionToCyberLogin = (event) => {
39
+ const isRedirectionToLogin = (event) => {
46
40
  const isRedirection = event.status === 302 /* Found */;
47
- const location = event.headers.get('Location');
48
- return isRedirection && location?.includes(CYBER_LOGIN_PATH);
41
+ const locationHeader = event.headers.get('Location');
42
+ const isLocationCyberLogin = locationHeader?.includes(CYBER_LOGIN_PATH);
43
+ const isLocationAcvLogin = locationHeader?.includes(ACV_LOGIN_PATH);
44
+ return isRedirection && (isLocationCyberLogin || isLocationAcvLogin);
49
45
  };
50
46
  class IamExpiredInterceptorService {
51
47
  constructor() {
52
- this._iamExpirationHeaderPresence = new Subject();
48
+ this._isIamSessionExpired = new Subject();
53
49
  }
54
- get iamExpirationHeaderPresence() {
55
- return this._iamExpirationHeaderPresence.asObservable();
50
+ get isIamSessionExpired() {
51
+ return this._isIamSessionExpired.asObservable();
56
52
  }
57
53
  intercept(req, next) {
58
54
  return next.handle(req).pipe(map(event => {
59
55
  if (event instanceof HttpResponse) {
60
56
  if (isIamExpiredHeader(event) ||
61
- isRedirectionToIamACV(event) ||
62
- isRedirectionToCyberLogin(event)) {
63
- this._iamExpirationHeaderPresence.next(true);
57
+ isRedirectionToLogin(event)) {
58
+ this._isIamSessionExpired.next(true);
64
59
  }
65
60
  }
66
61
  return event;
@@ -68,11 +63,11 @@ class IamExpiredInterceptorService {
68
63
  }
69
64
  handleError(err) {
70
65
  if (err instanceof HttpErrorResponse) {
71
- if (err.status === 200) {
72
- const isLogin = err.url.indexOf(CYBER_LOGIN_PATH) > 0;
73
- if (isLogin) {
74
- this._iamExpirationHeaderPresence.next(true);
75
- }
66
+ const isStatusOk = err.status === 200 /* Ok */;
67
+ const isUrlCyberLogin = err.url.includes(CYBER_LOGIN_PATH);
68
+ const isUrlAcvLogin = err.url.includes(ACV_LOGIN_PATH);
69
+ if (isStatusOk && (isUrlCyberLogin || isUrlAcvLogin)) {
70
+ this._isIamSessionExpired.next(true);
76
71
  }
77
72
  }
78
73
  return throwError(err);
@@ -9937,7 +9932,7 @@ class RedirectComponent {
9937
9932
  this.modalHeaderText = 'Information';
9938
9933
  this.modalBodyText = `<p>Votre session a expiré.</p>
9939
9934
  <p>Vous pouvez vous connecter à nouveau pour continuer à utiliser nos services.</p>`;
9940
- this.iamInterceptor.iamExpirationHeaderPresence
9935
+ this.iamInterceptor.isIamSessionExpired
9941
9936
  .pipe(first())
9942
9937
  .subscribe(() => this.showModal());
9943
9938
  }