@zengenti/contensis-react-base 3.0.0-beta.21 → 3.0.0-beta.25

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.
Files changed (61) hide show
  1. package/cjs/{App-9522e75e.js → App-ce39a877.js} +6 -6
  2. package/cjs/{App-9522e75e.js.map → App-ce39a877.js.map} +1 -1
  3. package/cjs/{RouteLoader-0f7fb3d8.js → RouteLoader-2ed14766.js} +2 -2
  4. package/cjs/{RouteLoader-0f7fb3d8.js.map → RouteLoader-2ed14766.js.map} +1 -1
  5. package/cjs/{ToJs-5da8a85e.js → ToJs-09204afd.js} +17 -12
  6. package/cjs/ToJs-09204afd.js.map +1 -0
  7. package/cjs/client.js +6 -6
  8. package/cjs/contensis-react-base.js +6 -6
  9. package/cjs/{login-2346691a.js → login-d67b82aa.js} +88 -51
  10. package/cjs/login-d67b82aa.js.map +1 -0
  11. package/cjs/{reducers-60dafd94.js → reducers-3a4f8971.js} +25 -24
  12. package/cjs/reducers-3a4f8971.js.map +1 -0
  13. package/cjs/redux.js +2 -2
  14. package/cjs/routing.js +2 -2
  15. package/cjs/search.js +7 -4
  16. package/cjs/search.js.map +1 -1
  17. package/cjs/user.js +19 -10
  18. package/cjs/user.js.map +1 -1
  19. package/cjs/{version-270b678d.js → version-7c4ce67e.js} +2 -2
  20. package/cjs/{version-270b678d.js.map → version-7c4ce67e.js.map} +1 -1
  21. package/esm/{App-b320f938.js → App-0d28106a.js} +6 -6
  22. package/esm/{App-b320f938.js.map → App-0d28106a.js.map} +1 -1
  23. package/esm/{RouteLoader-31425b61.js → RouteLoader-d4b4d320.js} +2 -2
  24. package/esm/{RouteLoader-31425b61.js.map → RouteLoader-d4b4d320.js.map} +1 -1
  25. package/esm/{ToJs-1f2e6395.js → ToJs-2627ce21.js} +16 -10
  26. package/esm/ToJs-2627ce21.js.map +1 -0
  27. package/esm/client.js +7 -7
  28. package/esm/contensis-react-base.js +7 -7
  29. package/esm/{login-af3b93c4.js → login-f6dfbe1b.js} +88 -51
  30. package/esm/login-f6dfbe1b.js.map +1 -0
  31. package/esm/{reducers-6f6801ed.js → reducers-8e5d6232.js} +25 -24
  32. package/esm/reducers-8e5d6232.js.map +1 -0
  33. package/esm/redux.js +3 -3
  34. package/esm/routing.js +2 -2
  35. package/esm/search.js +7 -4
  36. package/esm/search.js.map +1 -1
  37. package/esm/user.js +21 -12
  38. package/esm/user.js.map +1 -1
  39. package/esm/{version-be00bbb4.js → version-e6a545e1.js} +2 -2
  40. package/esm/{version-be00bbb4.js.map → version-e6a545e1.js.map} +1 -1
  41. package/models/redux/appstate.d.ts +5 -6
  42. package/models/search/models/SearchActions.d.ts +1 -0
  43. package/models/search/models/index.d.ts +1 -0
  44. package/models/search/redux/sagas.d.ts +2 -2
  45. package/models/search/redux/selectors.d.ts +1 -0
  46. package/models/user/components/Login.d.ts +1 -2
  47. package/models/user/components/LoginForm.d.ts +1 -2
  48. package/models/user/hocs/withLogin.d.ts +2 -2
  49. package/models/user/hooks/useLogin.d.ts +5 -3
  50. package/models/user/redux/reducers.d.ts +4 -5
  51. package/models/user/redux/sagas/login.d.ts +11 -8
  52. package/models/user/redux/selectors.d.ts +7 -2
  53. package/models/user/util/LoginHelper.class.d.ts +4 -3
  54. package/package-lock.json +2 -2
  55. package/package.json +1 -1
  56. package/cjs/ToJs-5da8a85e.js.map +0 -1
  57. package/cjs/login-2346691a.js.map +0 -1
  58. package/cjs/reducers-60dafd94.js.map +0 -1
  59. package/esm/ToJs-1f2e6395.js.map +0 -1
  60. package/esm/login-af3b93c4.js.map +0 -1
  61. package/esm/reducers-6f6801ed.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToJs-09204afd.js","sources":["../src/user/redux/selectors.ts","../src/user/util/matchGroups.ts","../src/util/ToJs.tsx"],"sourcesContent":["import { StateType } from '~/config';\nimport { AppState } from '~/redux/appstate';\nimport { getImmutableOrJS as getIn } from '~/redux/util';\n\nexport const selectUserIsLoading = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isLoading']);\n\nexport const selectUserIsAuthenticated = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isAuthenticated']);\n\nexport const selectUserIsAuthenticationError = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isAuthenticationError']);\n\nexport const selectUserIsError = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isError']);\n\n/**\n * DEPRECATED 12/2021 - use selectUserErrorMessage instead\n * @param state AppState\n * @returns string\n */\nexport const selectUserAuthenticationErrorMessage = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'errorMessage']);\n\nexport const selectUserErrorMessage = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'errorMessage']);\n\nexport const selectClientCredentials = (\n state: AppState,\n returnType?: StateType\n) =>\n getIn(\n state,\n ['user', 'authenticationState', 'clientCredentials'],\n {},\n returnType\n );\n\nexport const selectUser = (state: AppState, returnType?: StateType) =>\n getIn(state, 'user', {}, returnType);\n\nexport const selectUserIsZengentiStaff = (state: AppState) =>\n getIn(state, ['user', 'isZengentiStaff']);\n\nexport const selectUserGuid = (state: AppState) => getIn(state, ['user', 'id']);\n\nexport const selectUsername = (state: AppState) =>\n getIn(state, ['user', 'username']);\n\nexport const selectUserEmail = (state: AppState) =>\n getIn(state, ['user', 'email']);\n\nexport const selectUserGroups = (state: AppState, returnType?: StateType) =>\n getIn(state, ['user', 'groups'], [], returnType);\n\nexport const selectUserSecurityToken = (state: AppState) =>\n getIn(state, [\n 'user',\n 'authenticationState',\n 'clientCredentials',\n 'contensisClassicToken',\n ]);\n\nexport const selectUserRegistration = (\n state: AppState,\n returnType?: StateType\n) => getIn(state, ['user', 'registration'], {}, returnType);\n\nexport const selectUserRegistrationError = (state: AppState) =>\n getIn(state, ['user', 'registration', 'error'], false);\n\nexport const selectUserRegistrationIsLoading = (state: AppState) =>\n getIn(state, ['user', 'registration', 'isLoading'], false);\n\nexport const selectUserRegistrationIsSuccess = (state: AppState) =>\n getIn(state, ['user', 'registration', 'success'], false);\n\nexport const selectPasswordResetRequestSending = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'isSending']);\n\nexport const selectPasswordResetRequestSent = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'sent']);\n\nexport const selectPasswordResetRequestError = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'error']);\n\nexport const selectResetPasswordSending = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'isSending']);\n\nexport const selectResetPasswordSent = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'sent']);\n\nexport const selectResetPasswordError = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'error']);\n\nexport const selectChangePasswordSending = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'isSending']);\n\nexport const selectChangePasswordSent = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'sent']);\n\nexport const selectChangePasswordError = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'error']);\n","import { Group } from 'contensis-management-api/lib/models';\nimport { RequireLogin } from '~/routing/routes';\n\nexport const matchUserGroup = (\n userGroups: Group[] = [],\n requiredGroups: RequireLogin = []\n) => {\n if (\n !Array.isArray(requiredGroups) ||\n (Array.isArray(requiredGroups) && requiredGroups.length === 0)\n )\n return true;\n\n const groupMatch = requiredGroups.some(requiredGroup => {\n return userGroups.some(userGroup => {\n if (requiredGroup.id === userGroup.id) {\n return true;\n }\n if (requiredGroup.name === userGroup.name) {\n return true;\n }\n });\n });\n return groupMatch;\n};\n","/* eslint-disable react/display-name */\n/* eslint-disable @typescript-eslint/naming-convention */\nimport React from 'react';\n\nexport const toJS =\n <Props extends { [key: string]: any }>(\n WrappedComponent: React.ComponentType<Props>\n ): React.ComponentType<Props> =>\n (wrappedComponentProps: Props) => {\n const KEY = 0;\n const VALUE = 1;\n\n const propsJS = Object.entries(wrappedComponentProps).reduce<Props>(\n (newProps: any, wrappedComponentProp) => {\n const propKey = wrappedComponentProp[KEY];\n const propValue = wrappedComponentProp[VALUE];\n newProps[propKey] =\n propValue && typeof propValue === 'object' && 'toJS' in propValue\n ? propValue.toJS()\n : propValue;\n return newProps as Props;\n },\n {} as Props\n );\n\n return <WrappedComponent {...propsJS} />;\n };\n"],"names":["selectUserIsLoading","state","getIn","selectUserIsAuthenticated","selectUserIsAuthenticationError","selectUserIsError","selectUserAuthenticationErrorMessage","selectUserErrorMessage","selectClientCredentials","returnType","selectUser","selectUserIsZengentiStaff","selectUserGuid","selectUsername","selectUserEmail","selectUserGroups","selectUserSecurityToken","selectUserRegistration","selectUserRegistrationError","selectUserRegistrationIsLoading","selectUserRegistrationIsSuccess","selectPasswordResetRequestSending","selectPasswordResetRequestSent","selectPasswordResetRequestError","selectResetPasswordSending","selectResetPasswordSent","selectResetPasswordError","selectChangePasswordSending","selectChangePasswordSent","selectChangePasswordError","matchUserGroup","userGroups","requiredGroups","Array","isArray","length","groupMatch","some","requiredGroup","userGroup","id","name","toJS","WrappedComponent","wrappedComponentProps","KEY","VALUE","propsJS","Object","entries","reduce","newProps","wrappedComponentProp","propKey","propValue","React"],"mappings":";;;;;;;;;MAIaA,mBAAmB,GAAIC,KAAD,IACjCC,4BAAK,CAACD,KAAD,EAAQ,CAAC,MAAD,EAAS,qBAAT,EAAgC,WAAhC,CAAR;MAEME,yBAAyB,GAAIF,KAAD,IACvCC,4BAAK,CAACD,KAAD,EAAQ,CAAC,MAAD,EAAS,qBAAT,EAAgC,iBAAhC,CAAR;MAEMG,+BAA+B,GAAIH,KAAD,IAC7CC,4BAAK,CAACD,KAAD,EAAQ,CAAC,MAAD,EAAS,qBAAT,EAAgC,uBAAhC,CAAR;MAEMI,iBAAiB,GAAIJ,KAAD,IAC/BC,4BAAK,CAACD,KAAD,EAAQ,CAAC,MAAD,EAAS,qBAAT,EAAgC,SAAhC,CAAR;AAEP;AACA;AACA;AACA;AACA;;AACO,MAAMK,oCAAoC,GAAIL,KAAD,IAClDC,4BAAK,CAACD,KAAD,E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SAAxD,GACIA,SAAS,CAACZ,IAAV,EADJ,GAEIY,SAHN;AAIA,WAAOH,QAAP;AACD,GATa,EAUd,EAVc,CAAhB;AAaA,sBAAOI,wCAAC,gBAAD,EAAsBR,OAAtB,CAAP;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/cjs/client.js CHANGED
@@ -10,8 +10,8 @@ var reactRedux = require('react-redux');
10
10
  var reactRouterDom = require('react-router-dom');
11
11
  var component = require('@loadable/component');
12
12
  var queryString = require('query-string');
13
- var version = require('./version-270b678d.js');
14
- var App = require('./App-9522e75e.js');
13
+ var version = require('./version-7c4ce67e.js');
14
+ var App = require('./App-ce39a877.js');
15
15
  var actions = require('./actions-6b9ef168.js');
16
16
  require('./selectors-2c1b1183.js');
17
17
  require('jsonpath-mapper');
@@ -22,16 +22,16 @@ require('redux-saga');
22
22
  require('redux-injectors');
23
23
  require('immer');
24
24
  require('deepmerge');
25
- require('./reducers-60dafd94.js');
25
+ require('./reducers-3a4f8971.js');
26
26
  require('history');
27
27
  require('contensis-delivery-api');
28
28
  require('./version-dcfdafd9.js');
29
29
  require('loglevel');
30
- require('./login-2346691a.js');
31
- require('./ToJs-5da8a85e.js');
30
+ require('./login-d67b82aa.js');
31
+ require('./ToJs-09204afd.js');
32
32
  require('await-to-js');
33
33
  require('js-cookie');
34
- require('./RouteLoader-0f7fb3d8.js');
34
+ require('./RouteLoader-2ed14766.js');
35
35
  require('react-router-config');
36
36
  require('reselect');
37
37
 
@@ -19,8 +19,8 @@ var serialize = require('serialize-javascript');
19
19
  var minifyCssString = require('minify-css-string');
20
20
  var mapJson = require('jsonpath-mapper');
21
21
  var server = require('@loadable/server');
22
- var version = require('./version-270b678d.js');
23
- var App = require('./App-9522e75e.js');
22
+ var version = require('./version-7c4ce67e.js');
23
+ var App = require('./App-ce39a877.js');
24
24
  var actions = require('./actions-6b9ef168.js');
25
25
  var selectors = require('./selectors-2c1b1183.js');
26
26
  require('@redux-saga/core/effects');
@@ -30,18 +30,18 @@ require('redux-saga');
30
30
  require('redux-injectors');
31
31
  require('immer');
32
32
  require('deepmerge');
33
- require('./reducers-60dafd94.js');
33
+ require('./reducers-3a4f8971.js');
34
34
  require('history');
35
35
  require('contensis-delivery-api');
36
36
  require('./version-dcfdafd9.js');
37
37
  require('loglevel');
38
- require('./login-2346691a.js');
39
- require('./ToJs-5da8a85e.js');
38
+ require('./login-d67b82aa.js');
39
+ require('./ToJs-09204afd.js');
40
40
  require('await-to-js');
41
41
  require('js-cookie');
42
42
  require('react-hot-loader');
43
43
  require('query-string');
44
- require('./RouteLoader-0f7fb3d8.js');
44
+ require('./RouteLoader-2ed14766.js');
45
45
  require('reselect');
46
46
 
47
47
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var effects = require('@redux-saga/core/effects');
4
- var reducers = require('./reducers-60dafd94.js');
5
- var ToJs = require('./ToJs-5da8a85e.js');
4
+ var reducers = require('./reducers-3a4f8971.js');
5
+ var ToJs = require('./ToJs-09204afd.js');
6
6
  var actions = require('./actions-6b9ef168.js');
7
7
  var selectors = require('./selectors-2c1b1183.js');
8
8
  var mapJson = require('jsonpath-mapper');
@@ -189,6 +189,21 @@ class LoginHelper {
189
189
  static ClearCachedCredentials() {
190
190
  CookieHelper.DeleteCookie(LOGIN_COOKIE);
191
191
  CookieHelper.DeleteCookie(REFRESH_TOKEN_COOKIE);
192
+
193
+ if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
194
+ // remove any oidc keys left over in localStorage
195
+ const {
196
+ localStorage
197
+ } = window;
198
+ const keys = [];
199
+
200
+ for (let i = 0; i < localStorage.length; i++) {
201
+ const key = localStorage.key(i);
202
+ if (typeof key === 'string' && key.startsWith('oidc.')) keys.push(localStorage.key(i));
203
+ }
204
+
205
+ keys.forEach(key => localStorage.removeItem(key));
206
+ }
192
207
  }
193
208
 
194
209
  static async LoginUser({
@@ -198,10 +213,10 @@ class LoginHelper {
198
213
  }) {
199
214
  let credentials = clientCredentials;
200
215
  let authenticationState = {
201
- authenticated: false,
202
- authenticationError: false,
203
- error: false,
204
- clientCredentials: null
216
+ clientCredentials: null,
217
+ isAuthenticated: false,
218
+ isAuthenticationError: false,
219
+ isError: false
205
220
  };
206
221
  let transientClient;
207
222
  let user;
@@ -216,14 +231,12 @@ class LoginHelper {
216
231
  const [loginError, clientBearerToken] = await awaitToJs.to(transientClient.ensureBearerToken()); // Problem getting token with username and password
217
232
 
218
233
  if (loginError) {
219
- const authenticationError = loginError.name.includes('ContensisAuthenticationError');
220
234
  authenticationState = {
221
- authenticated: false,
222
- authenticationError: authenticationError,
223
- authenticationErrorMessage: authenticationError && loginError.message || null,
224
- error: !authenticationError,
225
- errorMessage: !authenticationError && loginError.message || null,
226
- clientCredentials: null
235
+ clientCredentials: null,
236
+ errorMessage: loginError.message || null,
237
+ isAuthenticated: false,
238
+ isAuthenticationError: loginError.name.includes('ContensisAuthenticationError'),
239
+ isError: true
227
240
  };
228
241
  LoginHelper.ClearCachedCredentials();
229
242
  } // Got a token using username and password
@@ -234,10 +247,10 @@ class LoginHelper {
234
247
  credentials = mapClientCredentials(transientClient);
235
248
  LoginHelper.SetLoginCookies(credentials);
236
249
  authenticationState = {
237
- authenticated: true,
238
- authenticationError: false,
239
- error: false,
240
- clientCredentials: credentials
250
+ clientCredentials: credentials,
251
+ isAuthenticated: true,
252
+ isAuthenticationError: false,
253
+ isError: false
241
254
  };
242
255
  }
243
256
  } // If we have credentials supplied by a successful username and password login
@@ -251,13 +264,11 @@ class LoginHelper {
251
264
 
252
265
  if (error) {
253
266
  authenticationState = {
254
- authenticated: false,
255
- authenticationError: false,
256
- error: {
257
- message: error.message,
258
- stack: error.stack
259
- },
260
- clientCredentials: null
267
+ clientCredentials: null,
268
+ errorMessage: error.message,
269
+ isAuthenticated: false,
270
+ isAuthenticationError: false,
271
+ isError: true
261
272
  };
262
273
  LoginHelper.ClearCachedCredentials();
263
274
  } else {
@@ -266,10 +277,10 @@ class LoginHelper {
266
277
  LoginHelper.SetLoginCookies(latestCredentials);
267
278
  user = userDetails;
268
279
  authenticationState = {
269
- authenticated: true,
270
- authenticationError: false,
271
- error: false,
272
- clientCredentials: latestCredentials
280
+ clientCredentials: latestCredentials,
281
+ isAuthenticated: true,
282
+ isAuthenticationError: false,
283
+ isError: false
273
284
  };
274
285
  }
275
286
  }
@@ -341,6 +352,16 @@ class LoginHelper {
341
352
  });
342
353
  }
343
354
 
355
+ static RemoveSecurityTokenQuery() {
356
+ const params = new URLSearchParams(window.location.search);
357
+
358
+ if (params.has('securitytoken') || params.has('securityToken')) {
359
+ params.delete('securitytoken');
360
+ params.delete('securityToken');
361
+ window.location = `${window.location.pathname}${params.toString() ? `?${params}` : ''}`;
362
+ }
363
+ }
364
+
344
365
  static async WsFedLogout(redirectPath) {
345
366
  await fetch(`${LoginHelper.CMS_URL}/authenticate/logout?jsonResponseRequired=true`, {
346
367
  credentials: 'include'
@@ -348,6 +369,10 @@ class LoginHelper {
348
369
 
349
370
  if (redirectPath) {
350
371
  window.location = redirectPath;
372
+ } else {
373
+ // Explicitly check and remove any stale
374
+ // security token that may be in the query string
375
+ LoginHelper.RemoveSecurityTokenQuery();
351
376
  }
352
377
  }
353
378
 
@@ -507,32 +532,45 @@ function* handleRequiresLoginSaga(action) {
507
532
  function* validateUserSaga({
508
533
  securityToken
509
534
  }) {
510
- if (securityToken) {
511
- // If we have just a security token we will call a CMS endpoint
535
+ // Check for refreshToken in cookies
536
+ let clientCredentials = LoginHelper.GetCachedCredentials();
537
+
538
+ if (securityToken || clientCredentials.refreshToken) {
539
+ // We only attempt to validate the user if one of the stored
540
+ // tokens are found, in this case we set loading state manually
541
+ // so we don't need to set and unset loading if there are no stored
542
+ yield effects.put({
543
+ type: reducers.SET_AUTHENTICATION_STATE,
544
+ authenticationState: {
545
+ isLoading: true
546
+ }
547
+ }); // If we have just a security token we will call a CMS endpoint
512
548
  // and provide us with a RefreshToken cookie we can use during login
549
+
513
550
  const [error, refreshToken] = yield LoginHelper.GetCredentialsForSecurityToken(securityToken);
514
- if (refreshToken) LoginHelper.SetLoginCookies({
515
- contensisClassicToken: securityToken,
516
- refreshToken
517
- });
518
- if (error) yield effects.put({
551
+
552
+ if (refreshToken) {
553
+ // Set cookies and reload values
554
+ LoginHelper.SetLoginCookies({
555
+ contensisClassicToken: securityToken,
556
+ refreshToken
557
+ });
558
+ clientCredentials = LoginHelper.GetCachedCredentials();
559
+ } // Log the user in if a refreshToken is found
560
+
561
+
562
+ if (clientCredentials.refreshToken) yield effects.call(loginUserSaga, {
563
+ clientCredentials
564
+ });else if (error) yield effects.put({
519
565
  type: reducers.SET_AUTHENTICATION_STATE,
520
566
  authenticationState: {
521
- error: {
522
- message: error.message,
523
- stack: error.stack
524
- }
567
+ isError: true,
568
+ errorMessage: (error === null || error === void 0 ? void 0 : error.message) || error && 'toString' in error && error.toString()
525
569
  }
526
570
  });
527
- } // Check for refreshToken in cookies
571
+ } // Tell any callers have we successfully logged in?
528
572
 
529
573
 
530
- const clientCredentials = LoginHelper.GetCachedCredentials(); // Log the user in if a refreshToken is found
531
-
532
- if (clientCredentials.refreshToken) yield effects.call(loginUserSaga, {
533
- clientCredentials
534
- }); // Tell any callers have we successfully logged in?
535
-
536
574
  return yield effects.select(ToJs.selectUserIsAuthenticated);
537
575
  }
538
576
 
@@ -602,12 +640,11 @@ function* refreshSecurityToken() {
602
640
  if (Object.keys(clientCredentials).length > 0) {
603
641
  const client = yield getManagementApiClient(clientCredentials);
604
642
  yield client.authenticate();
605
- const authenticationState = {};
606
- const newClientCredentials = mapClientCredentials(client);
607
- authenticationState.clientCredentials = newClientCredentials;
608
643
  yield effects.put({
609
644
  type: reducers.SET_AUTHENTICATION_STATE,
610
- authenticationState
645
+ authenticationState: {
646
+ clientCredentials: mapClientCredentials(client)
647
+ }
611
648
  });
612
649
  }
613
650
  }
@@ -618,4 +655,4 @@ exports.getManagementApiClient = getManagementApiClient;
618
655
  exports.handleRequiresLoginSaga = handleRequiresLoginSaga;
619
656
  exports.loginSagas = loginSagas;
620
657
  exports.refreshSecurityToken = refreshSecurityToken;
621
- //# sourceMappingURL=login-2346691a.js.map
658
+ //# sourceMappingURL=login-d67b82aa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-d67b82aa.js","sources":["../src/routing/util/find-contenttype-mapping.ts","../src/user/transformations/mapClientCredentials.js","../src/user/util/ContensisManagementApi.js","../src/user/util/CookieHelper.class.js","../src/user/util/OidcUserManager.js","../src/user/util/LoginHelper.class.js","../src/user/redux/sagas/login.js"],"sourcesContent":["import { ContentTypeMapping } from '../routes';\n\nexport const findContentTypeMapping = (\n ContentTypeMappings: ContentTypeMapping[],\n contentTypeId: string\n) => ContentTypeMappings.find(ct => ct.contentTypeID === contentTypeId);\n","import { mapJson } from '~/util/json-mapper';\n\nconst clientCredentials = {\n bearerToken: 'bearerToken',\n bearerTokenExpiryDate: ({ bearerTokenExpiryDate }) =>\n bearerTokenExpiryDate.toISOString(),\n refreshToken: 'refreshToken',\n refreshTokenExpiryDate: ({ refreshTokenExpiryDate }) =>\n refreshTokenExpiryDate.toISOString(),\n contensisClassicToken: 'contensisClassicToken',\n};\nexport default obj => mapJson(obj, clientCredentials);\n","// import { Client } from 'contensis-management-api';\n\nexport const getManagementApiClient = async ({\n bearerToken,\n bearerTokenExpiryDate,\n refreshToken,\n refreshTokenExpiryDate,\n contensisClassicToken,\n username,\n password,\n}) => {\n const rootUrl = SERVERS.api || SERVERS.cms; /* global SERVERS */\n const projectId = PROJECTS[0].id; /* global PROJECTS */\n\n let config = {};\n if (refreshToken) {\n config = {\n clientType: 'contensis_classic_refresh_token',\n clientDetails: {\n refreshToken,\n },\n };\n } else {\n config = {\n clientType: 'contensis_classic',\n clientDetails: {\n username,\n password,\n },\n };\n }\n const { Client } = await import('contensis-management-api');\n\n const client = Client.create({\n ...config,\n projectId,\n rootUrl,\n });\n\n if (bearerToken) client.bearerToken = bearerToken;\n if (bearerTokenExpiryDate)\n client.bearerTokenExpiryDate = bearerTokenExpiryDate;\n if (refreshToken) client.refreshToken = refreshToken;\n if (refreshTokenExpiryDate)\n client.refreshTokenExpiryDate = refreshTokenExpiryDate;\n if (contensisClassicToken)\n client.contensisClassicToken = contensisClassicToken;\n\n return client;\n};\n","import Cookies from 'js-cookie';\n\nconst COOKIE_VALID_DAYS = 1; // 0 = Session cookie\n\n// Override the default js-cookie conversion / encoding\n// methods so the written values work with Contensis sites\nconst _cookie = Cookies.withConverter({\n read: value => decodeURIComponent(value),\n write: value => encodeURIComponent(value),\n});\n\nexport class CookieHelper {\n static GetCookie(name) {\n let cookie = _cookie.get(name);\n if (typeof cookie == 'undefined') {\n return null;\n }\n return cookie;\n }\n\n static SetCookie(name, value, maxAgeDays = COOKIE_VALID_DAYS) {\n maxAgeDays === 0\n ? _cookie.set(name, value)\n : _cookie.set(name, value, { expires: maxAgeDays });\n }\n\n static DeleteCookie(name) {\n _cookie.remove(name);\n }\n}\n","const context = typeof window != 'undefined' ? window : global;\nconst requireOidc =\n process.env.NODE_ENV === 'development'\n ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */\n : context.WSFED_LOGIN === 'true';\n\nconst servers = SERVERS; /* global SERVERS */\n\nexport const userManagerConfig =\n typeof window !== 'undefined'\n ? {\n authority: `${servers.cms}/authenticate/`,\n client_id: 'WebsiteAdfsClient',\n redirect_uri: window.location.toString(),\n post_logout_redirect_uri: window.location.toString(),\n response_type: 'id_token',\n scope: 'openid',\n filterProtocolClaims: false,\n }\n : {};\n\nexport const createUserManager = async config => {\n if (typeof window !== 'undefined' && requireOidc) {\n try {\n const { UserManager } = await import(\n /* webpackChunkName: \"oidcclient\" */ 'oidc-client'\n );\n return new UserManager(config);\n } catch (e) {\n // eslint-disable-next-line no-console\n console.log('Exception in createUserManager: ', e);\n }\n } else return {};\n};\n\n//const userManager = createUserManager(userManagerConfig);\n\n// export default userManager;\n","/* eslint-disable require-atomic-updates */\nimport { getManagementApiClient } from './ContensisManagementApi';\nimport { to } from 'await-to-js';\n\nimport { CookieHelper } from './CookieHelper.class';\n\nimport mapClientCredentials from '../transformations/mapClientCredentials';\nimport { createUserManager, userManagerConfig } from './OidcUserManager';\n\nexport const LOGIN_COOKIE = 'ContensisCMSUserName';\nexport const REFRESH_TOKEN_COOKIE = 'RefreshToken';\n\nconst context = typeof window != 'undefined' ? window : global;\n\nexport class LoginHelper {\n static CMS_URL = SERVERS.cms /* global SERVERS */;\n static WSFED_LOGIN =\n process.env.NODE_ENV === 'development'\n ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */\n : context.WSFED_LOGIN === 'true';\n static LOGIN_ROUTE = '/account/login';\n static ACCESS_DENIED_ROUTE = '/account/access-denied';\n\n static SetLoginCookies({ contensisClassicToken, refreshToken }) {\n console.info(\n 'SetLoginCookies:',\n LOGIN_COOKIE,\n contensisClassicToken,\n REFRESH_TOKEN_COOKIE,\n refreshToken\n );\n if (contensisClassicToken)\n CookieHelper.SetCookie(LOGIN_COOKIE, contensisClassicToken);\n if (refreshToken)\n CookieHelper.SetCookie(REFRESH_TOKEN_COOKIE, refreshToken);\n }\n\n static GetCachedCredentials() {\n return {\n bearerToken: null,\n bearerTokenExpiryDate: null,\n refreshToken: CookieHelper.GetCookie(REFRESH_TOKEN_COOKIE),\n refreshTokenExpiryDate: null,\n contensisClassicToken: CookieHelper.GetCookie(LOGIN_COOKIE),\n };\n }\n\n static ClearCachedCredentials() {\n CookieHelper.DeleteCookie(LOGIN_COOKIE);\n CookieHelper.DeleteCookie(REFRESH_TOKEN_COOKIE);\n\n if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {\n // remove any oidc keys left over in localStorage\n const { localStorage } = window;\n const keys = [];\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (typeof key === 'string' && key.startsWith('oidc.'))\n keys.push(localStorage.key(i));\n }\n keys.forEach(key => localStorage.removeItem(key));\n }\n }\n\n static async LoginUser({ username, password, clientCredentials }) {\n let credentials = clientCredentials;\n let authenticationState = {\n clientCredentials: null,\n isAuthenticated: false,\n isAuthenticationError: false,\n isError: false,\n };\n let transientClient;\n let user;\n\n if (username && password) {\n // Get a management client with username and password\n transientClient = await getManagementApiClient({\n username,\n password,\n });\n\n // Ensure the client has requested a bearer token\n const [loginError, clientBearerToken] = await to(\n transientClient.ensureBearerToken()\n );\n\n // Problem getting token with username and password\n if (loginError) {\n authenticationState = {\n clientCredentials: null,\n errorMessage: loginError.message || null,\n isAuthenticated: false,\n isAuthenticationError: loginError.name.includes(\n 'ContensisAuthenticationError'\n ),\n isError: true,\n };\n LoginHelper.ClearCachedCredentials();\n }\n\n // Got a token using username and password\n if (clientBearerToken) {\n // Set credentials so we can continue to GetUserDetails\n credentials = mapClientCredentials(transientClient);\n LoginHelper.SetLoginCookies(credentials);\n authenticationState = {\n clientCredentials: credentials,\n isAuthenticated: true,\n isAuthenticationError: false,\n isError: false,\n };\n }\n }\n\n // If we have credentials supplied by a successful username and password login\n // or clientCredentials supplied in the options argument we can continue to\n // fetch the user's details\n if (credentials) {\n const client =\n transientClient || (await getManagementApiClient(credentials));\n const [error, userDetails] = await LoginHelper.GetUserDetails(client);\n\n if (error) {\n authenticationState = {\n clientCredentials: null,\n errorMessage: error.message,\n isAuthenticated: false,\n isAuthenticationError: false,\n isError: true,\n };\n LoginHelper.ClearCachedCredentials();\n } else {\n // Ensure we get latest refreshToken and contensisClassicToken from the latest client\n const latestCredentials = mapClientCredentials(client);\n LoginHelper.SetLoginCookies(latestCredentials);\n\n user = userDetails;\n authenticationState = {\n clientCredentials: latestCredentials,\n isAuthenticated: true,\n isAuthenticationError: false,\n isError: false,\n };\n }\n }\n\n return { authenticationState, user };\n }\n\n static GetUserDetails = async client => {\n let userError,\n groupsError,\n user = {},\n groupsResult;\n\n [userError, user] = await to(client.security.users.getCurrent());\n if (user && user.id) {\n [groupsError, groupsResult] = await to(\n client.security.users.getUserGroups({\n userId: user.id,\n includeInherited: true,\n })\n );\n // Set groups attribute in user object to be the items\n // array from the getUserGroups result\n if (groupsResult && groupsResult.items) user.groups = groupsResult.items;\n\n //If groups call fails then log the error but allow the user to login still\n // eslint-disable-next-line no-console\n if (groupsError) console.log(groupsError);\n }\n return [userError, user];\n };\n\n static LogoutUser(redirectPath) {\n LoginHelper.ClearCachedCredentials();\n if (LoginHelper.WSFED_LOGIN) {\n LoginHelper.WsFedLogout(redirectPath);\n } else {\n if (redirectPath) LoginHelper.ClientRedirectToPath(redirectPath);\n else LoginHelper.ClientRedirectToSignInPage();\n }\n }\n\n static ClientRedirectToHome(location) {\n if (typeof window != 'undefined') {\n let url = '/';\n if (location) {\n const { search, hash } = location;\n url = search ? `${url}${search}` : url;\n url = hash ? `${url}${hash}` : url;\n }\n window.location.href = url;\n }\n }\n\n static async ClientRedirectToSignInPage(redirectPath) {\n if (LoginHelper.WSFED_LOGIN) {\n await LoginHelper.WsFedLogout();\n await LoginHelper.WsFedLogin();\n } else {\n // Standard Contensis Login\n let url = LoginHelper.LOGIN_ROUTE;\n if (typeof redirectPath === 'string')\n url = `${url}?redirect_uri=${redirectPath}`;\n if (\n typeof location !== 'undefined' &&\n redirectPath !== LoginHelper.LOGIN_ROUTE\n )\n location.replace(url);\n }\n }\n\n static ClientRedirectToAccessDeniedPage(originalPath) {\n let url = LoginHelper.ACCESS_DENIED_ROUTE;\n if (originalPath === url) return;\n\n if (typeof originalPath === 'string')\n url = `${url}?original_uri=${originalPath}`;\n if (typeof location !== 'undefined') location.href = url;\n }\n\n static ClientRedirectToPath(redirectPath) {\n if (typeof redirectPath === 'string') {\n if (typeof location !== 'undefined') window.location.href = redirectPath;\n } else LoginHelper.ClientRedirectToHome();\n }\n\n static async WsFedLogin(redirectUri) {\n const userManager = await createUserManager(userManagerConfig);\n userManager.signinRedirect({\n scope: 'openid',\n response_type: 'id_token',\n redirect_uri: redirectUri || window.location.toString(),\n });\n }\n\n static RemoveSecurityTokenQuery() {\n const params = new URLSearchParams(window.location.search);\n if (params.has('securitytoken') || params.has('securityToken')) {\n params.delete('securitytoken');\n params.delete('securityToken');\n window.location = `${window.location.pathname}${\n params.toString() ? `?${params}` : ''\n }`;\n }\n }\n\n static async WsFedLogout(redirectPath) {\n await fetch(\n `${LoginHelper.CMS_URL}/authenticate/logout?jsonResponseRequired=true`,\n {\n credentials: 'include',\n }\n );\n if (redirectPath) {\n window.location = redirectPath;\n } else {\n // Explicitly check and remove any stale\n // security token that may be in the query string\n LoginHelper.RemoveSecurityTokenQuery();\n }\n }\n\n static async GetCredentialsForSecurityToken(securityToken) {\n const [error, response] = await to(\n fetch(`${LoginHelper.CMS_URL}/REST/Contensis/Security/IsAuthenticated`, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n securityToken: encodeURIComponent(securityToken),\n }),\n })\n );\n if (error) return [{ message: 'Failed to fetch credentials' }];\n if (response.ok) {\n const [parseError, body] = await to(response.json());\n if (parseError) return [parseError];\n\n const { LogonResult, ApplicationData = [] } = body;\n if (LogonResult !== 0) {\n return [\n { message: 'Security token is invalid', data: ApplicationData },\n ];\n }\n if (ApplicationData.length > 0) {\n let refreshToken;\n ApplicationData.forEach(item => {\n if (item.Key === 'ContensisSecurityRefreshToken')\n refreshToken = item.Value;\n });\n if (!refreshToken) {\n return [\n {\n message:\n 'Fetch credentials: Unable to find ContensisSecurityRefreshToken',\n },\n ];\n }\n return [undefined, refreshToken];\n } else {\n return [\n {\n message:\n 'Fetch credentials: Unable to find ContensisSecurityRefreshToken',\n },\n ];\n }\n } else {\n return [\n {\n message: `Fetch credentials error: ${response.status} ${response.statusText}`,\n },\n ];\n }\n }\n\n static isZengentiStaff(email) {\n const emailRefs = ['@zengenti', '@contensis'];\n\n return emailRefs.some(emailRef => {\n if (email.includes(emailRef)) {\n return true;\n }\n });\n }\n}\n","import { takeEvery, select, put, call } from 'redux-saga/effects';\nimport {\n SET_AUTHENTICATION_STATE,\n LOGIN_USER,\n LOGOUT_USER,\n VALIDATE_USER,\n} from '../types';\nimport {\n selectUserIsAuthenticated,\n selectClientCredentials,\n selectUserGroups,\n} from '../selectors';\n\nimport { setRoute } from '~/routing/redux/actions';\nimport { selectCurrentSearch } from '~/routing/redux/selectors';\nimport { findContentTypeMapping } from '~/routing/util/find-contenttype-mapping';\n\nimport mapClientCredentials from '~/user/transformations/mapClientCredentials';\n\nimport { getManagementApiClient } from '~/user/util/ContensisManagementApi';\nimport { LoginHelper } from '~/user/util/LoginHelper.class';\nimport { matchUserGroup } from '~/user/util/matchGroups';\nimport { queryParams } from '~/util/navigation';\n\nexport const loginSagas = [\n takeEvery(LOGIN_USER, loginUserSaga),\n takeEvery(LOGOUT_USER, logoutUserSaga),\n takeEvery(VALIDATE_USER, validateUserSaga),\n takeEvery(SET_AUTHENTICATION_STATE, redirectAfterSuccessfulLoginSaga),\n];\n\nexport function* handleRequiresLoginSaga(action) {\n const {\n entry,\n requireLogin,\n routes: { ContentTypeMappings },\n staticRoute,\n } = action;\n let userLoggedIn = yield select(selectUserIsAuthenticated);\n\n // Check for a securityToken in querystring\n const currentQs = queryParams(yield select(selectCurrentSearch));\n const securityToken = currentQs.securityToken || currentQs.securitytoken;\n\n // Check if any of the defined routes have \"requireLogin\" attribute\n const { requireLogin: authRoute } = (staticRoute && staticRoute.route) || {};\n const { requireLogin: authContentType } =\n (entry &&\n findContentTypeMapping(ContentTypeMappings, entry?.sys?.contentTypeId)) ||\n {};\n\n // If requireLogin, authRoute or authContentType has been specified as an\n // array of groups we can merge all the arrays and match on any group supplied\n const routeRequiresGroups = [\n ...((Array.isArray(authContentType) && authContentType) || []),\n ...((Array.isArray(authRoute) && authRoute) || []),\n ...((Array.isArray(requireLogin) && requireLogin) || []),\n ];\n const routeRequiresLogin = !!authContentType || !!authRoute || !!requireLogin;\n\n if (!userLoggedIn) {\n // If cookies or securityToken are found on any route change\n // always validate and login the user\n if (routeRequiresLogin) {\n // If routeRequiresLogin do a blocking call that returns userLoggedIn\n userLoggedIn = yield call(validateUserSaga, { securityToken });\n }\n // otherwise do a non blocking put to handle validation in the background\n else yield put({ type: VALIDATE_USER, securityToken });\n }\n\n if (routeRequiresLogin) {\n // If a security token is in the querystring and we are not already\n // logged in something is wrong and we won't bother going on another redirect loop\n if (!userLoggedIn && !securityToken) {\n LoginHelper.ClientRedirectToSignInPage(action.location.pathname);\n } else if (routeRequiresGroups.length > 0) {\n const userGroups = yield select(selectUserGroups, 'js');\n const groupMatch = matchUserGroup(userGroups, routeRequiresGroups);\n\n if (!groupMatch)\n LoginHelper.ClientRedirectToAccessDeniedPage(action.location.pathname);\n }\n }\n}\n\nfunction* validateUserSaga({ securityToken }) {\n // Check for refreshToken in cookies\n let clientCredentials = LoginHelper.GetCachedCredentials();\n\n if (securityToken || clientCredentials.refreshToken) {\n // We only attempt to validate the user if one of the stored\n // tokens are found, in this case we set loading state manually\n // so we don't need to set and unset loading if there are no stored\n yield put({\n type: SET_AUTHENTICATION_STATE,\n authenticationState: {\n isLoading: true,\n },\n });\n // If we have just a security token we will call a CMS endpoint\n // and provide us with a RefreshToken cookie we can use during login\n const [error, refreshToken] =\n yield LoginHelper.GetCredentialsForSecurityToken(securityToken);\n if (refreshToken) {\n // Set cookies and reload values\n LoginHelper.SetLoginCookies({\n contensisClassicToken: securityToken,\n refreshToken,\n });\n clientCredentials = LoginHelper.GetCachedCredentials();\n }\n\n // Log the user in if a refreshToken is found\n if (clientCredentials.refreshToken)\n yield call(loginUserSaga, { clientCredentials });\n else if (error)\n yield put({\n type: SET_AUTHENTICATION_STATE,\n authenticationState: {\n isError: true,\n errorMessage:\n error?.message ||\n (error && 'toString' in error && error.toString()),\n },\n });\n }\n\n // Tell any callers have we successfully logged in?\n return yield select(selectUserIsAuthenticated);\n}\n\nfunction* loginUserSaga(action = {}) {\n const { username, password, clientCredentials } = action;\n\n // If a WSFED_LOGIN site has dispatched the loginUser action\n // just redirect them to the Identity Provider sign in\n if (action.type === LOGIN_USER && LoginHelper.WSFED_LOGIN)\n LoginHelper.ClientRedirectToSignInPage();\n\n const { authenticationState, user } = yield LoginHelper.LoginUser({\n username,\n password,\n clientCredentials,\n });\n\n yield put({\n type: SET_AUTHENTICATION_STATE,\n authenticationState,\n user,\n });\n}\nconst removeHostnamePart = path => {\n // eslint-disable-next-line no-console\n console.log(path);\n const relativePath = '/' + path.split('/').splice(3).join('/');\n // eslint-disable-next-line no-console\n console.log(relativePath);\n return relativePath;\n};\n\nfunction* redirectAfterSuccessfulLoginSaga() {\n const isLoggedIn = yield select(selectUserIsAuthenticated);\n const { redirect_uri: redirectPath, ReturnURL: assetRedirectPath } =\n queryParams(yield select(selectCurrentSearch));\n\n if (isLoggedIn && assetRedirectPath && typeof window != 'undefined') {\n const path = removeHostnamePart(assetRedirectPath);\n // This has to be a hard href to get the app to\n // leave React and hit the server for the IIS hosted assets\n window.location.href = path;\n // yield put(setRoute(path)); // does not work in this scenario\n } else if (isLoggedIn && redirectPath) {\n yield put(setRoute(redirectPath));\n }\n}\n\nfunction* logoutUserSaga({ redirectPath }) {\n yield put({\n type: SET_AUTHENTICATION_STATE,\n user: null,\n });\n yield LoginHelper.LogoutUser(redirectPath);\n}\n\nexport function* refreshSecurityToken() {\n const clientCredentials = yield select(selectClientCredentials, 'js');\n if (Object.keys(clientCredentials).length > 0) {\n const client = yield getManagementApiClient(clientCredentials);\n yield client.authenticate();\n\n yield put({\n type: SET_AUTHENTICATION_STATE,\n authenticationState: {\n clientCredentials: mapClientCredentials(client),\n },\n });\n }\n}\n"],"names":["findContentTypeMapping","ContentTypeMappings","contentTypeId","find","ct","contentTypeID","clientCredentials","bearerToken","bearerTokenExpiryDate","toISOString","refreshToken","refreshTokenExpiryDate","contensisClassicToken","obj","mapJson","getManagementApiClient","username","password","rootUrl","SERVERS","api","cms","projectId","PROJECTS","id","config","clientType","clientDetails","Client","client","create","COOKIE_VALID_DAYS","_cookie","Cookies","withConverter","read","value","decodeURIComponent","write","encodeURIComponent","CookieHelper","GetCookie","name","cookie","get","SetCookie","maxAgeDays","set","expires","DeleteCookie","remove","context","window","global","requireOidc","process","env","NODE_ENV","WSFED_LOGIN","servers","userManagerConfig","authority","client_id","redirect_uri","location","toString","post_logout_redirect_uri","response_type","scope","filterProtocolClaims","createUserManager","UserManager","e","console","log","LOGIN_COOKIE","REFRESH_TOKEN_COOKIE","LoginHelper","SetLoginCookies","info","GetCachedCredentials","ClearCachedCredentials","localStorage","keys","i","length","key","startsWith","push","forEach","removeItem","LoginUser","credentials","authenticationState","isAuthenticated","isAuthenticationError","isError","transientClient","user","loginError","clientBearerToken","to","ensureBearerToken","errorMessage","message","includes","mapClientCredentials","error","userDetails","GetUserDetails","latestCredentials","LogoutUser","redirectPath","WsFedLogout","ClientRedirectToPath","ClientRedirectToSignInPage","ClientRedirectToHome","url","search","hash","href","WsFedLogin","LOGIN_ROUTE","replace","ClientRedirectToAccessDeniedPage","originalPath","ACCESS_DENIED_ROUTE","redirectUri","userManager","signinRedirect","RemoveSecurityTokenQuery","params","URLSearchParams","has","delete","pathname","fetch","CMS_URL","GetCredentialsForSecurityToken","securityToken","response","method","headers","Accept","body","JSON","stringify","ok","parseError","json","LogonResult","ApplicationData","data","item","Key","Value","undefined","status","statusText","isZengentiStaff","email","emailRefs","some","emailRef","userError","groupsError","groupsResult","security","users","getCurrent","getUserGroups","userId","includeInherited","items","groups","loginSagas","takeEvery","LOGIN_USER","loginUserSaga","LOGOUT_USER","logoutUserSaga","VALIDATE_USER","validateUserSaga","SET_AUTHENTICATION_STATE","redirectAfterSuccessfulLoginSaga","handleRequiresLoginSaga","action","entry","requireLogin","routes","staticRoute","userLoggedIn","select","selectUserIsAuthenticated","currentQs","queryParams","selectCurrentSearch","securitytoken","authRoute","route","authContentType","sys","routeRequiresGroups","Array","isArray","routeRequiresLogin","call","put","type","userGroups","selectUserGroups","groupMatch","matchUserGroup","isLoading","removeHostnamePart","path","relativePath","split","splice","join","isLoggedIn","ReturnURL","assetRedirectPath","setRoute","refreshSecur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AM0L,cAAM,CAACiC,4BAAD,EAA0B,IAA1B,CAAtC;;AACA,MAAIC,MAAM,CAAC/I,IAAP,CAAY7E,iBAAZ,EAA+B+E,MAA/B,GAAwC,CAA5C,EAA+C;AAC7C,UAAMxD,MAAM,GAAG,MAAMd,sBAAsB,CAACT,iBAAD,CAA3C;AACA,UAAMuB,MAAM,CAACsM,YAAP,EAAN;AAEA,UAAMpB,WAAG,CAAC;AACRC,MAAAA,IAAI,EAAEzB,iCADE;AAER1F,MAAAA,mBAAmB,EAAE;AACnBvF,QAAAA,iBAAiB,EAAEoG,oBAAoB,CAAC7E,MAAD;AADpB;AAFb,KAAD,CAAT;AAMD;AACF;;;;;;;;;"}
@@ -51,13 +51,12 @@ var types = /*#__PURE__*/Object.freeze({
51
51
  });
52
52
 
53
53
  const defaultAuthenticationState = {
54
- authenticated: false,
55
- authenticationError: false,
56
- authenticationErrorMessage: null,
57
54
  clientCredentials: null,
58
- error: false,
59
55
  errorMessage: null,
60
- loading: false
56
+ isAuthenticated: false,
57
+ isAuthenticationError: false,
58
+ isError: false,
59
+ isLoading: false
61
60
  };
62
61
  const defaultPasswordResetRequestValues = {
63
62
  isSending: false,
@@ -75,7 +74,7 @@ const defaultChangePasswordValues = {
75
74
  error: null
76
75
  };
77
76
  const defaultRegistrationValues = {
78
- loading: false,
77
+ isLoading: false,
79
78
  success: false,
80
79
  error: null
81
80
  };
@@ -88,8 +87,12 @@ const initialUserState = {
88
87
  };
89
88
  var UserReducer = immer.produce((state, action) => {
90
89
  switch (action.type) {
91
- case LOGIN_USER:
92
90
  case LOGOUT_USER:
91
+ {
92
+ return initialUserState;
93
+ }
94
+
95
+ case LOGIN_USER:
93
96
  case SET_AUTHENTICATION_STATE:
94
97
  {
95
98
  var _state, _state$authentication;
@@ -98,43 +101,41 @@ var UserReducer = immer.produce((state, action) => {
98
101
  action.authenticationState = defaultAuthenticationState;
99
102
  }
100
103
 
101
- const loading = action.type === LOGIN_USER;
102
104
  const {
103
105
  authenticationState: {
104
- error = false,
106
+ clientCredentials = null,
105
107
  errorMessage = null,
106
- authenticated,
107
- authenticationError = false,
108
- authenticationErrorMessage = null,
109
- clientCredentials = null
108
+ isAuthenticated,
109
+ isAuthenticationError = false,
110
+ isError = false,
111
+ isLoading = action.type === LOGIN_USER
110
112
  },
111
113
  user
112
114
  } = action;
113
115
 
114
116
  if (user) {
115
- user.name = `${user.firstName} ${user.lastName}`;
117
+ user.name = `${user.firstName}${user.lastName ? ` ${user.lastName}` : ''}` || null;
116
118
  user.isZengentiStaff = user.email.includes('@zengenti.com');
117
119
  }
118
120
 
119
121
  state = { ...initialUserState,
120
122
  ...(user || state),
121
123
  authenticationState: {
122
- authenticated: authenticated || ((_state = state) === null || _state === void 0 ? void 0 : (_state$authentication = _state.authenticationState) === null || _state$authentication === void 0 ? void 0 : _state$authentication.authenticated),
123
- authenticationError,
124
- authenticationErrorMessage,
125
124
  clientCredentials,
126
- error,
127
125
  errorMessage,
128
- loading
126
+ isAuthenticated: isAuthenticated || ((_state = state) === null || _state === void 0 ? void 0 : (_state$authentication = _state.authenticationState) === null || _state$authentication === void 0 ? void 0 : _state$authentication.isAuthenticated),
127
+ isAuthenticationError,
128
+ isError,
129
+ isLoading
129
130
  }
130
131
  };
131
132
  return state;
132
133
  }
133
134
  // REGISTER_USER is the trigger to set the user.registration initial state
134
- // and will set user.registration.loading to true
135
- // REGISTER_USER_FAILED will unset user.registration.loading and will set
135
+ // and will set user.registration.isLoading to true
136
+ // REGISTER_USER_FAILED will unset user.registration.isLoading and will set
136
137
  // the value in user.registration.error
137
- // REGISTER_USER_SUCCESS will unset user.registration.loading and will
138
+ // REGISTER_USER_SUCCESS will unset user.registration.isLoading and will
138
139
  // set user.registration to the created user from the api response
139
140
 
140
141
  case REGISTER_USER:
@@ -151,7 +152,7 @@ var UserReducer = immer.produce((state, action) => {
151
152
 
152
153
  state.registration.success = action.type === REGISTER_USER_SUCCESS;
153
154
  state.registration.error = error || false;
154
- state.registration.loading = action.type === REGISTER_USER;
155
+ state.registration.isLoading = action.type === REGISTER_USER;
155
156
  return;
156
157
  }
157
158
 
@@ -249,4 +250,4 @@ exports.UserReducer = UserReducer;
249
250
  exports.VALIDATE_USER = VALIDATE_USER;
250
251
  exports.initialUserState = initialUserState;
251
252
  exports.types = types;
252
- //# sourceMappingURL=reducers-60dafd94.js.map
253
+ //# sourceMappingURL=reducers-3a4f8971.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reducers-3a4f8971.js","sources":["../src/user/redux/types.js","../src/user/redux/reducers.ts"],"sourcesContent":["const ACTION_PREFIX = '@USER/';\nexport const VALIDATE_USER = `${ACTION_PREFIX}VALIDATE_USER`;\nexport const SET_AUTHENTICATION_STATE = `${ACTION_PREFIX}SET_AUTHENTICATION_STATE`;\nexport const LOGIN_USER = `${ACTION_PREFIX}LOGIN_USER`;\nexport const LOGIN_SUCCESSFUL = `${ACTION_PREFIX}LOGIN_SUCCESSFUL`;\nexport const LOGIN_FAILED = `${ACTION_PREFIX}LOGIN_FAILED`;\nexport const LOGOUT_USER = `${ACTION_PREFIX}LOGOUT_USER`;\nexport const REGISTER_USER = `${ACTION_PREFIX}REGISTER_USER`;\nexport const REGISTER_USER_SUCCESS = `${ACTION_PREFIX}REGISTER_USER_SUCCESS`;\nexport const REGISTER_USER_FAILED = `${ACTION_PREFIX}REGISTER_USER_FAILED`;\n\nexport const REQUEST_USER_PASSWORD_RESET = `${ACTION_PREFIX}REQUEST_USER_PASSWORD_RESET`;\nexport const RESET_USER_PASSWORD = `${ACTION_PREFIX}RESET_USER_PASSWORD`;\nexport const REQUEST_USER_PASSWORD_RESET_SENDING = `${ACTION_PREFIX}REQUEST_USER_PASSWORD_RESET_SENDING`;\nexport const REQUEST_USER_PASSWORD_RESET_SUCCESS = `${ACTION_PREFIX}REQUEST_USER_PASSWORD_RESET_SUCCESS`;\nexport const REQUEST_USER_PASSWORD_RESET_ERROR = `${ACTION_PREFIX}REQUEST_USER_PASSWORD_RESET_ERROR`;\nexport const RESET_USER_PASSWORD_SENDING = `${ACTION_PREFIX}RESET_USER_PASSWORD_SENDING`;\nexport const RESET_USER_PASSWORD_SUCCESS = `${ACTION_PREFIX}RESET_USER_PASSWORD_SUCCESS`;\nexport const RESET_USER_PASSWORD_ERROR = `${ACTION_PREFIX}RESET_USER_PASSWORD_ERROR`;\n\nexport const CHANGE_USER_PASSWORD = `${ACTION_PREFIX}CHANGE_USER_PASSWORD`;\nexport const CHANGE_USER_PASSWORD_SENDING = `${ACTION_PREFIX}CHANGE_USER_PASSWORD_SENDING`;\nexport const CHANGE_USER_PASSWORD_SUCCESS = `${ACTION_PREFIX}CHANGE_USER_PASSWORD_SUCCESS`;\nexport const CHANGE_USER_PASSWORD_ERROR = `${ACTION_PREFIX}CHANGE_USER_PASSWORD_ERROR`;\n","import { Draft, produce } from 'immer';\nimport { AppState } from '~/redux/appstate';\nimport {\n REGISTER_USER,\n REGISTER_USER_FAILED,\n REGISTER_USER_SUCCESS,\n SET_AUTHENTICATION_STATE,\n LOGIN_USER,\n LOGOUT_USER,\n REQUEST_USER_PASSWORD_RESET_SENDING,\n REQUEST_USER_PASSWORD_RESET_SUCCESS,\n REQUEST_USER_PASSWORD_RESET_ERROR,\n RESET_USER_PASSWORD_SENDING,\n RESET_USER_PASSWORD_SUCCESS,\n RESET_USER_PASSWORD_ERROR,\n CHANGE_USER_PASSWORD_SENDING,\n CHANGE_USER_PASSWORD_SUCCESS,\n CHANGE_USER_PASSWORD_ERROR,\n} from './types';\n\nconst defaultAuthenticationState = {\n clientCredentials: null,\n errorMessage: null,\n isAuthenticated: false,\n isAuthenticationError: false,\n isError: false,\n isLoading: false,\n};\n\nconst defaultPasswordResetRequestValues = {\n isSending: false,\n sent: false,\n error: null,\n};\n\nconst defaultResetPasswordValues = {\n isSending: false,\n sent: false,\n error: null,\n};\n\nconst defaultChangePasswordValues = {\n isSending: false,\n sent: false,\n error: null,\n};\n\nconst defaultRegistrationValues = {\n isLoading: false,\n success: false,\n error: null,\n};\n\nexport const initialUserState = {\n authenticationState: defaultAuthenticationState,\n passwordResetRequest: defaultPasswordResetRequestValues,\n resetPassword: defaultResetPasswordValues,\n changePassword: defaultChangePasswordValues,\n groups: [],\n};\n\nexport default produce((state: Draft<AppState['user']>, action) => {\n switch (action.type) {\n case LOGOUT_USER: {\n return initialUserState;\n }\n case LOGIN_USER:\n case SET_AUTHENTICATION_STATE: {\n if (!action.authenticationState) {\n action.authenticationState = defaultAuthenticationState;\n }\n\n const {\n authenticationState: {\n clientCredentials = null,\n errorMessage = null,\n isAuthenticated,\n isAuthenticationError = false,\n isError = false,\n isLoading = action.type === LOGIN_USER,\n },\n user,\n } = action;\n\n if (user) {\n user.name =\n `${user.firstName}${user.lastName ? ` ${user.lastName}` : ''}` ||\n null;\n user.isZengentiStaff = user.email.includes('@zengenti.com');\n }\n\n state = {\n ...initialUserState,\n ...(user || state),\n authenticationState: {\n clientCredentials,\n errorMessage,\n isAuthenticated:\n isAuthenticated || state?.authenticationState?.isAuthenticated,\n isAuthenticationError,\n isError,\n isLoading,\n },\n };\n return state;\n }\n // REGISTER_USER is the trigger to set the user.registration initial state\n // and will set user.registration.isLoading to true\n // REGISTER_USER_FAILED will unset user.registration.isLoading and will set\n // the value in user.registration.error\n // REGISTER_USER_SUCCESS will unset user.registration.isLoading and will\n // set user.registration to the created user from the api response\n case REGISTER_USER:\n case REGISTER_USER_FAILED:\n case REGISTER_USER_SUCCESS: {\n const { error, user } = action;\n\n // Set registration object from the supplied action.user\n // so we can call these values back later\n state.registration = (user ||\n state.registration ||\n defaultRegistrationValues) as typeof defaultRegistrationValues;\n\n // Set registration flags so the UI can track the status\n state.registration.success = action.type === REGISTER_USER_SUCCESS;\n state.registration.error = error || false;\n state.registration.isLoading = action.type === REGISTER_USER;\n return;\n }\n case REQUEST_USER_PASSWORD_RESET_SENDING:\n state.passwordResetRequest = defaultPasswordResetRequestValues;\n state.passwordResetRequest.isSending = true;\n return;\n case REQUEST_USER_PASSWORD_RESET_SUCCESS:\n if (state.passwordResetRequest) {\n state.passwordResetRequest.isSending = false;\n state.passwordResetRequest.sent = true;\n }\n return;\n case REQUEST_USER_PASSWORD_RESET_ERROR:\n if (state.passwordResetRequest) {\n state.passwordResetRequest.isSending = false;\n state.passwordResetRequest.error = action.error;\n }\n return;\n case RESET_USER_PASSWORD_SENDING:\n if (state.resetPassword) {\n state.resetPassword.isSending = true;\n }\n return;\n case RESET_USER_PASSWORD_SUCCESS:\n if (state.resetPassword) {\n state.resetPassword.isSending = false;\n state.resetPassword.sent = true;\n }\n return;\n case RESET_USER_PASSWORD_ERROR:\n if (state.resetPassword) {\n state.resetPassword.isSending = false;\n state.resetPassword.error = action.error;\n }\n return;\n case CHANGE_USER_PASSWORD_SENDING:\n if (state.changePassword) {\n state.changePassword.isSending = true;\n }\n return;\n case CHANGE_USER_PASSWORD_SUCCESS:\n if (state.changePassword) {\n state.changePassword.isSending = false;\n state.changePassword.sent = true;\n }\n return;\n case CHANGE_USER_PASSWORD_ERROR:\n if (state.changePassword) {\n state.changePassword.isSending = false;\n state.changePassword.error = action.error;\n }\n return;\n default:\n return;\n }\n}, initialUserState);\n"],"names":["ACTION_PREFIX","VALIDATE_USER","SET_AUTHENTICATION_STATE","LOGIN_USER","LOGIN_SUCCESSFUL","LOGIN_FAILED","LOGOUT_USER","REGISTER_USER","REGISTER_USER_SUCCESS","REGISTER_USER_FAILED","REQUEST_USER_PASSWORD_RESET","RESET_USER_PASSWORD","REQUEST_USER_PASSWORD_RESET_SENDING","REQUEST_USER_PASSWORD_RESET_SUCCESS","REQUEST_USER_PASSWORD_RESET_ERROR","RESET_USER_PASSWORD_SENDING","RESET_USER_PASSWORD_SUCCESS","RESET_USER_PASSWORD_ERROR","CHANGE_USER_PASSWORD","CHANGE_USER_PASSWORD_SENDING","CHANGE_USER_PASSWORD_SUCCESS","CHANGE_USER_PASSWORD_ERROR","defaultAuthenticationState","clientCredentials","errorMessage","isAuthenticated","isAuthenticationError","isError","isLoading","defaultPasswordResetRequestValues","isSending","sent","error","defaultResetPasswordValues","defaultChangePasswordValues","defaultRegistrationValues","success","initialUserState","authenticationState","passwordResetRequest","resetPassword","changePassword","groups","produce","state","action","type","user","name","firstName","lastName","isZengentiStaff","email","includes","registration"],"mappings":";;;;AAAA,MAAMA,aAAa,GAAG,QAAtB;MACaC,aAAa,GAAI,GAAED,aAAc;MACjCE,wBAAwB,GAAI,GAAEF,aAAc;MAC5CG,UAAU,GAAI,GAAEH,aAAc;AACpC,MAAMI,gBAAgB,GAAI,GAAEJ,aAAc,kBAA1C;AACA,MAAMK,YAAY,GAAI,GAAEL,aAAc,cAAtC;MACMM,WAAW,GAAI,GAAEN,aAAc;MAC/BO,aAAa,GAAI,GAAEP,aAAc;MACjCQ,qBAAqB,GAAI,GAAER,aAAc;MACzCS,oBAAoB,GAAI,GAAET,aAAc;MAExCU,2BAA2B,GAAI,GAAEV,aAAc;MAC/CW,mBAAmB,GAAI,GAAEX,aAAc;MACvCY,mCAAmC,GAAI,GAAEZ,aAAc;MACvDa,mCAAmC,GAAI,GAAEb,aAAc;MACvDc,iCAAiC,GAAI,GAAEd,aAAc;MACrDe,2BAA2B,GAAI,GAAEf,aAAc;MAC/CgB,2BAA2B,GAAI,GAAEhB,aAAc;MAC/CiB,yBAAyB,GAAI,GAAEjB,aAAc;MAE7CkB,oBAAoB,GAAI,GAAElB,aAAc;MACxCmB,4BAA4B,GAAI,GAAEnB,aAAc;MAChDoB,4BAA4B,GAAI,GAAEpB,aAAc;MAChDqB,0BAA0B,GAAI,GAAErB,aAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;ACH3D,MAAMsB,0BAA0B,GAAG;AACjCC,EAAAA,iBAAiB,EAAE,IADc;AAEjCC,EAAAA,YAAY,EAAE,IAFmB;AAGjCC,EAAAA,eAAe,EAAE,KAHgB;AAIjCC,EAAAA,qBAAqB,EAAE,KAJU;AAKjCC,EAAAA,OAAO,EAAE,KALwB;AAMjCC,EAAAA,SAAS,EAAE;AAN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KAAK,CAACH,cAAV,EAA0B;AACxBG,QAAAA,KAAK,CAACH,cAAN,CAAqBX,SAArB,GAAiC,IAAjC;AACD;;AACD;;AACF,SAAKV,4BAAL;AACE,UAAIwB,KAAK,CAACH,cAAV,EAA0B;AACxBG,QAAAA,KAAK,CAACH,cAAN,CAAqBX,SAArB,GAAiC,KAAjC;AACAc,QAAAA,KAAK,CAACH,cAAN,CAAqBV,IAArB,GAA4B,IAA5B;AACD;;AACD;;AACF,SAAKV,0BAAL;AACE,UAAIuB,KAAK,CAACH,cAAV,EAA0B;AACxBG,QAAAA,KAAK,CAACH,cAAN,CAAqBX,SAArB,GAAiC,KAAjC;AACAc,QAAAA,KAAK,CAACH,cAAN,CAAqBT,KAArB,GAA6Ba,MAAM,CAACb,KAApC;AACD;;AACD;;AACF;AACE;AAtHJ;AAwHD,CAzHqB,EAyHnBK,gBAzHmB,CAAtB;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/cjs/redux.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version$1 = require('./version-270b678d.js');
5
+ var version$1 = require('./version-7c4ce67e.js');
6
6
  var actions$1 = require('./actions-6b9ef168.js');
7
7
  var selectors$1 = require('./selectors-2c1b1183.js');
8
8
  var version$2 = require('./version-dcfdafd9.js');
@@ -13,7 +13,7 @@ require('redux-saga');
13
13
  require('redux-injectors');
14
14
  require('immer');
15
15
  require('deepmerge');
16
- require('./reducers-60dafd94.js');
16
+ require('./reducers-3a4f8971.js');
17
17
  require('jsonpath-mapper');
18
18
  require('query-string');
19
19
 
package/cjs/routing.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var actions = require('./actions-6b9ef168.js');
6
6
  var selectors = require('./selectors-2c1b1183.js');
7
- var RouteLoader = require('./RouteLoader-0f7fb3d8.js');
7
+ var RouteLoader = require('./RouteLoader-2ed14766.js');
8
8
  require('jsonpath-mapper');
9
9
  require('query-string');
10
10
  require('react');
@@ -13,7 +13,7 @@ require('react-hot-loader');
13
13
  require('react-router-dom');
14
14
  require('react-router-config');
15
15
  require('reselect');
16
- require('./ToJs-5da8a85e.js');
16
+ require('./ToJs-09204afd.js');
17
17
 
18
18
 
19
19