@dsivd/prestations-ng 15.2.3-beta7 → 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.
@@ -33,16 +33,15 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
33
33
  const IAM_SESSION_EXPIRED_HEADER = 'iam-session-expired';
34
34
  const CYBER_LOGIN_PATH = '/100018/login';
35
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);
36
+ const isIamExpiredHeader = (event) => {
37
+ return !!event.headers.get(IAM_SESSION_EXPIRED_HEADER);
41
38
  };
42
- const isRedirectionToCyberLogin = (event) => {
39
+ const isRedirectionToLogin = (event) => {
43
40
  const isRedirection = event.status === 302 /* Found */;
44
- const location = event.headers.get('Location');
45
- 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);
46
45
  };
47
46
  class IamExpiredInterceptorService {
48
47
  constructor() {
@@ -53,11 +52,9 @@ class IamExpiredInterceptorService {
53
52
  }
54
53
  intercept(req, next) {
55
54
  return next.handle(req).pipe(map(event => {
56
- console.log('event', typeof event, event);
57
55
  if (event instanceof HttpResponse) {
58
56
  if (isIamExpiredHeader(event) ||
59
- isRedirectionToIamACV(event) ||
60
- isRedirectionToCyberLogin(event)) {
57
+ isRedirectionToLogin(event)) {
61
58
  this._isIamSessionExpired.next(true);
62
59
  }
63
60
  }
@@ -65,13 +62,12 @@ class IamExpiredInterceptorService {
65
62
  }), catchError(this.handleError.bind(this)));
66
63
  }
67
64
  handleError(err) {
68
- console.log('err', typeof err, err);
69
65
  if (err instanceof HttpErrorResponse) {
70
- if (err.status === 200 /* Ok */) {
71
- const isLogin = err.url.indexOf(CYBER_LOGIN_PATH) > 0;
72
- if (isLogin) {
73
- this._isIamSessionExpired.next(true);
74
- }
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);
75
71
  }
76
72
  }
77
73
  return throwError(err);