@dsivd/prestations-ng 15.2.3-beta3 → 15.2.3-beta6

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.
@@ -31,7 +31,22 @@ 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 LOGIN_PATH = '/100018/login';
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)));
44
+ };
45
+ const isRedirectionToCyberLogin = (event) => {
46
+ const isRedirection = event.status === 302 /* Found */;
47
+ const location = event.headers.get('Location');
48
+ return isRedirection && location?.includes(CYBER_LOGIN_PATH);
49
+ };
35
50
  class IamExpiredInterceptorService {
36
51
  constructor() {
37
52
  this._iamExpirationHeaderPresence = new Subject();
@@ -41,10 +56,11 @@ class IamExpiredInterceptorService {
41
56
  }
42
57
  intercept(req, next) {
43
58
  return next.handle(req).pipe(map(event => {
59
+ console.log('event', event);
44
60
  if (event instanceof HttpResponse) {
45
- // either we have the header 'iam-session-expired'
46
- const iamExpiredHeader = event.headers.get(IAM_SESSION_EXPIRED_HEADER);
47
- if (null !== iamExpiredHeader) {
61
+ if (isIamExpiredHeader(event) ||
62
+ isRedirectionToIamACV(event) ||
63
+ isRedirectionToCyberLogin(event)) {
48
64
  this._iamExpirationHeaderPresence.next(true);
49
65
  }
50
66
  }
@@ -54,7 +70,7 @@ class IamExpiredInterceptorService {
54
70
  handleError(err) {
55
71
  if (err instanceof HttpErrorResponse) {
56
72
  if (err.status === 200) {
57
- const isLogin = err.url.indexOf(LOGIN_PATH) > 0;
73
+ const isLogin = err.url.indexOf(CYBER_LOGIN_PATH) > 0;
58
74
  if (isLogin) {
59
75
  this._iamExpirationHeaderPresence.next(true);
60
76
  }
@@ -9917,45 +9933,33 @@ class TableSort {
9917
9933
  }
9918
9934
 
9919
9935
  class RedirectComponent {
9920
- constructor(iamInterceptor, foehnPageModalService) {
9936
+ constructor(iamInterceptor) {
9921
9937
  this.iamInterceptor = iamInterceptor;
9922
- this.foehnPageModalService = foehnPageModalService;
9923
- this.subscription = this.iamInterceptor.iamExpirationHeaderPresence.subscribe(() => this.showModal());
9924
- }
9925
- ngOnInit() {
9926
9938
  this.modalHeaderText = 'Information';
9927
9939
  this.modalBodyText = `<p>Votre session a expiré.</p>
9928
9940
  <p>Vous pouvez vous connecter à nouveau pour continuer à utiliser nos services.</p>`;
9929
- }
9930
- ngOnDestroy() {
9931
- this.subscription.unsubscribe();
9932
- }
9933
- redirect() {
9934
- this.foehnPageModalService
9935
- .buildSelfRedirectionThroughCyberLogin()
9936
- .pipe(first(), tap(redirectUrl => {
9937
- window.location.href = redirectUrl;
9938
- }))
9939
- .subscribe();
9941
+ this.iamInterceptor.iamExpirationHeaderPresence
9942
+ .pipe(first())
9943
+ .subscribe(() => this.showModal());
9940
9944
  }
9941
9945
  showModal() {
9942
9946
  this.counter = 10;
9943
9947
  this.isModalVisible = true;
9944
9948
  setInterval(() => {
9945
9949
  if (0 === this.counter) {
9946
- this.redirect();
9950
+ window.location.reload();
9947
9951
  return;
9948
9952
  }
9949
9953
  this.counter--;
9950
9954
  }, 1000);
9951
9955
  }
9952
9956
  }
9953
- RedirectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RedirectComponent, deps: [{ token: IamExpiredInterceptorService }, { token: FoehnPageModalService }], target: i0.ɵɵFactoryTarget.Component });
9957
+ RedirectComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RedirectComponent, deps: [{ token: IamExpiredInterceptorService }], target: i0.ɵɵFactoryTarget.Component });
9954
9958
  RedirectComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.5", type: RedirectComponent, selector: "redirector", ngImport: i0, template: "<foehn-modal\n [modalBodyText]=\"modalBodyText\"\n [isModalVisible]=\"isModalVisible\"\n [modalHeaderText]=\"modalHeaderText\"\n [closeable]=\"false\"\n>\n <div modal-footer class=\"w-100 text-right font-weight-bold\">\n Vous allez \u00EAtre redirig\u00E9 dans {{ counter }} s.\n </div>\n</foehn-modal>\n", components: [{ type: FoehnModalComponent, selector: "foehn-modal", inputs: ["id", "name", "modalSize", "modalBodyText", "modalHeaderText", "closeable", "modalTriggerHtmlElement", "isModalVisible"], outputs: ["isModalVisibleChange"] }] });
9955
9959
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.5", ngImport: i0, type: RedirectComponent, decorators: [{
9956
9960
  type: Component,
9957
9961
  args: [{ selector: 'redirector', template: "<foehn-modal\n [modalBodyText]=\"modalBodyText\"\n [isModalVisible]=\"isModalVisible\"\n [modalHeaderText]=\"modalHeaderText\"\n [closeable]=\"false\"\n>\n <div modal-footer class=\"w-100 text-right font-weight-bold\">\n Vous allez \u00EAtre redirig\u00E9 dans {{ counter }} s.\n </div>\n</foehn-modal>\n" }]
9958
- }], ctorParameters: function () { return [{ type: IamExpiredInterceptorService }, { type: FoehnPageModalService }]; } });
9962
+ }], ctorParameters: function () { return [{ type: IamExpiredInterceptorService }]; } });
9959
9963
 
9960
9964
  class SdkRedirectModule {
9961
9965
  }