@zengenti/contensis-react-base 3.0.2-beta.2 → 3.0.2-beta.21
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/cjs/{App-ee485b92.js → App-21a7d836.js} +120 -432
- package/cjs/App-21a7d836.js.map +1 -0
- package/cjs/ContensisDeliveryApi-c079b03a.js +231 -0
- package/cjs/ContensisDeliveryApi-c079b03a.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-7f0d107a.js} +23 -37
- package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-7f0d107a.js.map} +1 -1
- package/cjs/{ToJs-a9a8522b.js → ToJs-6e9cfa69.js} +3 -4
- package/cjs/{ToJs-a9a8522b.js.map → ToJs-6e9cfa69.js.map} +1 -1
- package/cjs/client.js +20 -27
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +124 -188
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +1488 -272
- package/cjs/forms.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-7c363211.js} +1 -4
- package/cjs/{fromJSLeaveImmer-e74c673c.js.map → fromJSLeaveImmer-7c363211.js.map} +1 -1
- package/cjs/{login-840860bc.js → login-2a6b5be0.js} +64 -113
- package/cjs/login-2a6b5be0.js.map +1 -0
- package/cjs/{reducers-3a4f8971.js → reducers-9afb5f89.js} +14 -31
- package/cjs/reducers-9afb5f89.js.map +1 -0
- package/cjs/redux.js +17 -17
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +6 -7
- package/cjs/routing.js.map +1 -1
- package/cjs/{sagas-8a20e424.js → sagas-e04b94c1.js} +225 -301
- package/cjs/sagas-e04b94c1.js.map +1 -0
- package/cjs/search.js +68 -94
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-656da4b7.js → selectors-bcca60f4.js} +89 -8
- package/cjs/selectors-bcca60f4.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +4 -13
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +45 -53
- package/cjs/util.js.map +1 -1
- package/cjs/{version-78dfc3bd.js → version-4077e706.js} +50 -159
- package/cjs/version-4077e706.js.map +1 -0
- package/cjs/version-fe28099e.js +98 -0
- package/cjs/version-fe28099e.js.map +1 -0
- package/esm/{App-640239d2.js → App-2af18a99.js} +102 -412
- package/esm/App-2af18a99.js.map +1 -0
- package/esm/ContensisDeliveryApi-5660ee0e.js +227 -0
- package/esm/ContensisDeliveryApi-5660ee0e.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-6eac364e.js} +22 -36
- package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-6eac364e.js.map} +1 -1
- package/esm/{ToJs-4e02a04d.js → ToJs-9b30636a.js} +3 -4
- package/esm/{ToJs-4e02a04d.js.map → ToJs-9b30636a.js.map} +1 -1
- package/esm/client.js +15 -22
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +119 -183
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +1490 -274
- package/esm/forms.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-e2dacd63.js} +1 -4
- package/esm/{fromJSLeaveImmer-0114ffcf.js.map → fromJSLeaveImmer-e2dacd63.js.map} +1 -1
- package/esm/{login-57395c9c.js → login-71ff3fcb.js} +63 -112
- package/esm/login-71ff3fcb.js.map +1 -0
- package/esm/{reducers-8e5d6232.js → reducers-3d5c37d1.js} +14 -31
- package/esm/reducers-3d5c37d1.js.map +1 -0
- package/esm/redux.js +9 -8
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +3 -4
- package/esm/routing.js.map +1 -1
- package/esm/{sagas-e576b6f6.js → sagas-933a8fc8.js} +177 -254
- package/esm/sagas-933a8fc8.js.map +1 -0
- package/esm/search.js +69 -95
- package/esm/search.js.map +1 -1
- package/esm/{selectors-a5e5835b.js → selectors-74de49a3.js} +75 -8
- package/esm/selectors-74de49a3.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +6 -15
- package/esm/user.js.map +1 -1
- package/esm/util.js +42 -53
- package/esm/util.js.map +1 -1
- package/esm/version-b15807c5.js +87 -0
- package/esm/version-b15807c5.js.map +1 -0
- package/esm/{version-e3a5ec66.js → version-ef107106.js} +37 -142
- package/esm/version-ef107106.js.map +1 -0
- package/models/redux/appstate.d.ts +1 -0
- package/models/routing/redux/selectors.d.ts +2 -1
- package/models/search/models/Queries.d.ts +2 -1
- package/models/search/models/Search.d.ts +2 -0
- package/models/search/models/SearchActions.d.ts +3 -3
- package/models/search/redux/actions.d.ts +6 -6
- package/models/search/redux/util.d.ts +1 -1
- package/models/search/search/expressions.d.ts +1 -1
- package/models/server/features/linkdepth-api/search.d.ts +1 -1
- package/models/util/ContensisDeliveryApi.d.ts +6 -0
- package/models/util/index.d.ts +1 -0
- package/package.json +1 -1
- package/cjs/App-ee485b92.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/login-840860bc.js.map +0 -1
- package/cjs/reducers-3a4f8971.js.map +0 -1
- package/cjs/sagas-8a20e424.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-78dfc3bd.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-640239d2.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.js.map +0 -1
- package/esm/login-57395c9c.js.map +0 -1
- package/esm/reducers-8e5d6232.js.map +0 -1
- package/esm/sagas-e576b6f6.js.map +0 -1
- package/esm/selectors-a5e5835b.js.map +0 -1
- package/esm/version-2485e2fb.js +0 -15
- package/esm/version-2485e2fb.js.map +0 -1
- package/esm/version-e3a5ec66.js.map +0 -1
|
@@ -3,12 +3,10 @@ import { Seq } from 'immutable';
|
|
|
3
3
|
const fromJSOrdered = js => {
|
|
4
4
|
return typeof js !== 'object' || js === null ? js : Array.isArray(js) ? Seq(js).map(fromJSOrdered).toList() : Seq(js).map(fromJSOrdered).toOrderedMap();
|
|
5
5
|
};
|
|
6
|
-
|
|
7
6
|
var fromJSOrdered$1 = fromJSOrdered;
|
|
8
7
|
|
|
9
8
|
const fromJSLeaveImmer = js => {
|
|
10
9
|
const immutableObj = fromJSOrdered$1(js);
|
|
11
|
-
|
|
12
10
|
if (immutableObj && 'set' in immutableObj && typeof immutableObj.set === 'function') {
|
|
13
11
|
// convert the immer parts of the state back
|
|
14
12
|
// to plain JS while retuning an immutable state object
|
|
@@ -18,9 +16,8 @@ const fromJSLeaveImmer = js => {
|
|
|
18
16
|
});
|
|
19
17
|
return immutableState;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
return immutableObj;
|
|
23
20
|
};
|
|
24
21
|
|
|
25
22
|
export { fromJSLeaveImmer as default };
|
|
26
|
-
//# sourceMappingURL=fromJSLeaveImmer-
|
|
23
|
+
//# sourceMappingURL=fromJSLeaveImmer-e2dacd63.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromJSLeaveImmer-
|
|
1
|
+
{"version":3,"file":"fromJSLeaveImmer-e2dacd63.js","sources":["../src/util/fromJSOrdered.js","../src/util/fromJSLeaveImmer.js"],"sourcesContent":["import { Seq } from 'immutable';\n\nconst fromJSOrdered = js => {\n return typeof js !== 'object' || js === null\n ? js\n : Array.isArray(js)\n ? Seq(js).map(fromJSOrdered).toList()\n : Seq(js).map(fromJSOrdered).toOrderedMap();\n};\n\nexport default fromJSOrdered;\n","import fromJSOrdered from './fromJSOrdered';\n\nconst fromJSLeaveImmer = js => {\n const immutableObj = fromJSOrdered(js);\n if (\n immutableObj &&\n 'set' in immutableObj &&\n typeof immutableObj.set === 'function'\n ) {\n // convert the immer parts of the state back\n // to plain JS while retuning an immutable state object\n let immutableState = immutableObj;\n [\n 'immer',\n 'form',\n 'forms',\n 'navigation',\n 'routing',\n 'search',\n 'user',\n 'version',\n ].map(key => {\n if (js[key] && immutableObj.get(key))\n immutableState = immutableState.set(key, js[key]);\n });\n return immutableState;\n }\n return immutableObj;\n};\nexport default fromJSLeaveImmer;\n"],"names":["fromJSOrdered","js","Array","isArray","Seq","map","toList","toOrderedMap","fromJSLeaveImmer","immutableObj","set","immutableState","key","get"],"mappings":";;AAEA,MAAMA,aAAa,GAAGC,EAAE,IAAI;AAC1B,EAAA,OAAO,OAAOA,EAAE,KAAK,QAAQ,IAAIA,EAAE,KAAK,IAAI,GACxCA,EAAE,GACFC,KAAK,CAACC,OAAO,CAACF,EAAE,CAAC,GACjBG,GAAG,CAACH,EAAE,CAAC,CAACI,GAAG,CAACL,aAAa,CAAC,CAACM,MAAM,EAAE,GACnCF,GAAG,CAACH,EAAE,CAAC,CAACI,GAAG,CAACL,aAAa,CAAC,CAACO,YAAY,EAAE,CAAA;AAC/C,CAAC,CAAA;AAED,sBAAeP,aAAa;;ACRtBQ,MAAAA,gBAAgB,GAAGP,EAAE,IAAI;AAC7B,EAAA,MAAMQ,YAAY,GAAGT,eAAa,CAACC,EAAE,CAAC,CAAA;AACtC,EAAA,IACEQ,YAAY,IACZ,KAAK,IAAIA,YAAY,IACrB,OAAOA,YAAY,CAACC,GAAG,KAAK,UAAU,EACtC;AACA;AACA;IACA,IAAIC,cAAc,GAAGF,YAAY,CAAA;IACjC,CACE,OAAO,EACP,MAAM,EACN,OAAO,EACP,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,SAAS,CACV,CAACJ,GAAG,CAACO,GAAG,IAAI;MACX,IAAIX,EAAE,CAACW,GAAG,CAAC,IAAIH,YAAY,CAACI,GAAG,CAACD,GAAG,CAAC,EAClCD,cAAc,GAAGA,cAAc,CAACD,GAAG,CAACE,GAAG,EAAEX,EAAE,CAACW,GAAG,CAAC,CAAC,CAAA;AACrD,KAAC,CAAC,CAAA;AACF,IAAA,OAAOD,cAAc,CAAA;AACvB,GAAA;AACA,EAAA,OAAOF,YAAY,CAAA;AACrB;;;;"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { takeEvery, put, call, select } from '@redux-saga/core/effects';
|
|
2
|
-
import { L as LOGIN_USER, n as LOGOUT_USER, V as VALIDATE_USER, S as SET_AUTHENTICATION_STATE } from './reducers-
|
|
3
|
-
import { a as selectUserIsAuthenticated, b as selectUserGroups, m as matchUserGroup, s as selectClientCredentials } from './ToJs-
|
|
4
|
-
import {
|
|
5
|
-
import { q as queryParams, j as selectCurrentSearch } from './selectors-a5e5835b.js';
|
|
2
|
+
import { L as LOGIN_USER, n as LOGOUT_USER, V as VALIDATE_USER, S as SET_AUTHENTICATION_STATE } from './reducers-3d5c37d1.js';
|
|
3
|
+
import { a as selectUserIsAuthenticated, b as selectUserGroups, m as matchUserGroup, s as selectClientCredentials } from './ToJs-9b30636a.js';
|
|
4
|
+
import { q as queryParams, o as selectCurrentSearch, p as setRoute } from './selectors-74de49a3.js';
|
|
6
5
|
import mapJson from 'jsonpath-mapper';
|
|
7
6
|
import { to } from 'await-to-js';
|
|
8
7
|
import JSCookie from 'js-cookie';
|
|
@@ -23,6 +22,7 @@ const clientCredentials = {
|
|
|
23
22
|
var mapClientCredentials = (obj => mapJson(obj, clientCredentials));
|
|
24
23
|
|
|
25
24
|
// import { Client } from 'contensis-management-api';
|
|
25
|
+
|
|
26
26
|
const getManagementApiClient = async ({
|
|
27
27
|
bearerToken,
|
|
28
28
|
bearerTokenExpiryDate,
|
|
@@ -32,14 +32,10 @@ const getManagementApiClient = async ({
|
|
|
32
32
|
username,
|
|
33
33
|
password
|
|
34
34
|
}) => {
|
|
35
|
-
const rootUrl = SERVERS.api || SERVERS.cms;
|
|
36
|
-
/* global
|
|
37
|
-
|
|
38
|
-
const projectId = PROJECTS[0].id;
|
|
39
|
-
/* global PROJECTS */
|
|
35
|
+
const rootUrl = SERVERS.api || SERVERS.cms; /* global SERVERS */
|
|
36
|
+
const projectId = PROJECTS[0].id; /* global PROJECTS */
|
|
40
37
|
|
|
41
38
|
let config = {};
|
|
42
|
-
|
|
43
39
|
if (refreshToken) {
|
|
44
40
|
config = {
|
|
45
41
|
clientType: 'contensis_classic_refresh_token',
|
|
@@ -56,11 +52,11 @@ const getManagementApiClient = async ({
|
|
|
56
52
|
}
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
|
-
|
|
60
55
|
const {
|
|
61
56
|
Client
|
|
62
57
|
} = await import('contensis-management-api');
|
|
63
|
-
const client = Client.create({
|
|
58
|
+
const client = Client.create({
|
|
59
|
+
...config,
|
|
64
60
|
projectId,
|
|
65
61
|
rootUrl
|
|
66
62
|
});
|
|
@@ -73,9 +69,9 @@ const getManagementApiClient = async ({
|
|
|
73
69
|
};
|
|
74
70
|
|
|
75
71
|
const COOKIE_VALID_DAYS = 1; // 0 = Session cookie
|
|
72
|
+
|
|
76
73
|
// Override the default js-cookie conversion / encoding
|
|
77
74
|
// methods so the written values work with Contensis sites
|
|
78
|
-
|
|
79
75
|
const Cookies = JSCookie.withConverter({
|
|
80
76
|
read: value => decodeURIComponent(value),
|
|
81
77
|
write: value => encodeURIComponent(value)
|
|
@@ -83,32 +79,24 @@ const Cookies = JSCookie.withConverter({
|
|
|
83
79
|
class CookieHelper {
|
|
84
80
|
static GetCookie(name) {
|
|
85
81
|
const cookie = Cookies.get(name);
|
|
86
|
-
|
|
87
82
|
if (typeof cookie === 'undefined') {
|
|
88
83
|
return null;
|
|
89
84
|
}
|
|
90
|
-
|
|
91
85
|
return cookie;
|
|
92
86
|
}
|
|
93
|
-
|
|
94
87
|
static SetCookie(name, value, maxAgeDays = COOKIE_VALID_DAYS) {
|
|
95
88
|
if (maxAgeDays === 0) Cookies.set(name, value);else Cookies.set(name, value, {
|
|
96
89
|
expires: maxAgeDays
|
|
97
90
|
});
|
|
98
91
|
}
|
|
99
|
-
|
|
100
92
|
static DeleteCookie(name) {
|
|
101
93
|
Cookies.remove(name);
|
|
102
94
|
}
|
|
103
|
-
|
|
104
95
|
}
|
|
105
96
|
|
|
106
97
|
const context$1 = typeof window != 'undefined' ? window : global;
|
|
107
|
-
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
108
|
-
/* global
|
|
109
|
-
: context$1.WSFED_LOGIN === 'true';
|
|
110
|
-
const servers = SERVERS;
|
|
111
|
-
/* global SERVERS */
|
|
98
|
+
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context$1.WSFED_LOGIN === 'true';
|
|
99
|
+
const servers = SERVERS; /* global SERVERS */
|
|
112
100
|
|
|
113
101
|
const userManagerConfig = typeof window !== 'undefined' ? {
|
|
114
102
|
authority: `${servers.cms}/authenticate/`,
|
|
@@ -124,9 +112,7 @@ const createUserManager = async config => {
|
|
|
124
112
|
try {
|
|
125
113
|
const {
|
|
126
114
|
UserManager
|
|
127
|
-
} = await import(
|
|
128
|
-
/* webpackChunkName: "oidcclient" */
|
|
129
|
-
'oidc-client');
|
|
115
|
+
} = await import( /* webpackChunkName: "oidcclient" */'oidc-client');
|
|
130
116
|
return new UserManager(config);
|
|
131
117
|
} catch (e) {
|
|
132
118
|
console.error('Exception in createUserManager: ', e);
|
|
@@ -147,7 +133,6 @@ class LoginHelper {
|
|
|
147
133
|
if (contensisClassicToken) CookieHelper.SetCookie(LOGIN_COOKIE, contensisClassicToken);
|
|
148
134
|
if (refreshToken) CookieHelper.SetCookie(REFRESH_TOKEN_COOKIE, refreshToken);
|
|
149
135
|
}
|
|
150
|
-
|
|
151
136
|
static GetCachedCredentials() {
|
|
152
137
|
return {
|
|
153
138
|
bearerToken: null,
|
|
@@ -157,27 +142,22 @@ class LoginHelper {
|
|
|
157
142
|
contensisClassicToken: CookieHelper.GetCookie(LOGIN_COOKIE)
|
|
158
143
|
};
|
|
159
144
|
}
|
|
160
|
-
|
|
161
145
|
static ClearCachedCredentials() {
|
|
162
146
|
CookieHelper.DeleteCookie(LOGIN_COOKIE);
|
|
163
147
|
CookieHelper.DeleteCookie(REFRESH_TOKEN_COOKIE);
|
|
164
|
-
|
|
165
148
|
if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
|
|
166
149
|
// remove any oidc keys left over in localStorage
|
|
167
150
|
const {
|
|
168
151
|
localStorage
|
|
169
152
|
} = window;
|
|
170
153
|
const keys = [];
|
|
171
|
-
|
|
172
154
|
for (let i = 0; i < localStorage.length; i++) {
|
|
173
155
|
const key = localStorage.key(i);
|
|
174
156
|
if (typeof key === 'string' && key.startsWith('oidc.')) keys.push(localStorage.key(i));
|
|
175
157
|
}
|
|
176
|
-
|
|
177
158
|
keys.forEach(key => localStorage.removeItem(key));
|
|
178
159
|
}
|
|
179
160
|
}
|
|
180
|
-
|
|
181
161
|
static async LoginUser({
|
|
182
162
|
username,
|
|
183
163
|
password,
|
|
@@ -192,16 +172,17 @@ class LoginHelper {
|
|
|
192
172
|
};
|
|
193
173
|
let transientClient;
|
|
194
174
|
let user;
|
|
195
|
-
|
|
196
175
|
if (username && password) {
|
|
197
176
|
// Get a management client with username and password
|
|
198
177
|
transientClient = await getManagementApiClient({
|
|
199
178
|
username,
|
|
200
179
|
password
|
|
201
|
-
});
|
|
180
|
+
});
|
|
202
181
|
|
|
203
|
-
|
|
182
|
+
// Ensure the client has requested a bearer token
|
|
183
|
+
const [loginError, clientBearerToken] = await to(transientClient.ensureBearerToken());
|
|
204
184
|
|
|
185
|
+
// Problem getting token with username and password
|
|
205
186
|
if (loginError) {
|
|
206
187
|
authenticationState = {
|
|
207
188
|
clientCredentials: null,
|
|
@@ -211,9 +192,9 @@ class LoginHelper {
|
|
|
211
192
|
isError: true
|
|
212
193
|
};
|
|
213
194
|
LoginHelper.ClearCachedCredentials();
|
|
214
|
-
}
|
|
215
|
-
|
|
195
|
+
}
|
|
216
196
|
|
|
197
|
+
// Got a token using username and password
|
|
217
198
|
if (clientBearerToken) {
|
|
218
199
|
// Set credentials so we can continue to GetUserDetails
|
|
219
200
|
credentials = mapClientCredentials(transientClient);
|
|
@@ -225,15 +206,14 @@ class LoginHelper {
|
|
|
225
206
|
isError: false
|
|
226
207
|
};
|
|
227
208
|
}
|
|
228
|
-
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// If we have credentials supplied by a successful username and password login
|
|
229
212
|
// or clientCredentials supplied in the options argument we can continue to
|
|
230
213
|
// fetch the user's details
|
|
231
|
-
|
|
232
|
-
|
|
233
214
|
if (credentials) {
|
|
234
215
|
const client = transientClient || (await getManagementApiClient(credentials));
|
|
235
216
|
const [error, userDetails] = await LoginHelper.GetUserDetails(client);
|
|
236
|
-
|
|
237
217
|
if (error) {
|
|
238
218
|
authenticationState = {
|
|
239
219
|
clientCredentials: null,
|
|
@@ -256,27 +236,22 @@ class LoginHelper {
|
|
|
256
236
|
};
|
|
257
237
|
}
|
|
258
238
|
}
|
|
259
|
-
|
|
260
239
|
return {
|
|
261
240
|
authenticationState,
|
|
262
241
|
user
|
|
263
242
|
};
|
|
264
243
|
}
|
|
265
|
-
|
|
266
244
|
static LogoutUser(redirectPath) {
|
|
267
245
|
LoginHelper.ClearCachedCredentials();
|
|
268
|
-
|
|
269
246
|
if (LoginHelper.WSFED_LOGIN) {
|
|
270
247
|
LoginHelper.WsFedLogout(redirectPath);
|
|
271
248
|
} else {
|
|
272
249
|
if (redirectPath) LoginHelper.ClientRedirectToPath(redirectPath);else LoginHelper.ClientRedirectToSignInPage();
|
|
273
250
|
}
|
|
274
251
|
}
|
|
275
|
-
|
|
276
252
|
static ClientRedirectToHome(location) {
|
|
277
253
|
if (typeof window != 'undefined') {
|
|
278
254
|
let url = '/';
|
|
279
|
-
|
|
280
255
|
if (location) {
|
|
281
256
|
const {
|
|
282
257
|
search,
|
|
@@ -285,11 +260,9 @@ class LoginHelper {
|
|
|
285
260
|
url = search ? `${url}${search}` : url;
|
|
286
261
|
url = hash ? `${url}${hash}` : url;
|
|
287
262
|
}
|
|
288
|
-
|
|
289
263
|
window.location.href = url;
|
|
290
264
|
}
|
|
291
265
|
}
|
|
292
|
-
|
|
293
266
|
static async ClientRedirectToSignInPage(redirectPath) {
|
|
294
267
|
if (LoginHelper.WSFED_LOGIN) {
|
|
295
268
|
await LoginHelper.WsFedLogout();
|
|
@@ -301,20 +274,17 @@ class LoginHelper {
|
|
|
301
274
|
if (typeof location !== 'undefined' && redirectPath !== LoginHelper.LOGIN_ROUTE) location.replace(url);
|
|
302
275
|
}
|
|
303
276
|
}
|
|
304
|
-
|
|
305
277
|
static ClientRedirectToAccessDeniedPage(originalPath) {
|
|
306
278
|
let url = LoginHelper.ACCESS_DENIED_ROUTE;
|
|
307
279
|
if (originalPath === url) return;
|
|
308
280
|
if (typeof originalPath === 'string') url = `${url}?original_uri=${originalPath}`;
|
|
309
281
|
if (typeof location !== 'undefined') location.href = url;
|
|
310
282
|
}
|
|
311
|
-
|
|
312
283
|
static ClientRedirectToPath(redirectPath) {
|
|
313
284
|
if (typeof redirectPath === 'string') {
|
|
314
285
|
if (typeof location !== 'undefined') window.location.href = redirectPath;
|
|
315
286
|
} else LoginHelper.ClientRedirectToHome();
|
|
316
287
|
}
|
|
317
|
-
|
|
318
288
|
static async WsFedLogin(redirectUri) {
|
|
319
289
|
const userManager = await createUserManager(userManagerConfig);
|
|
320
290
|
userManager.signinRedirect({
|
|
@@ -323,22 +293,18 @@ class LoginHelper {
|
|
|
323
293
|
redirect_uri: redirectUri || window.location.toString()
|
|
324
294
|
});
|
|
325
295
|
}
|
|
326
|
-
|
|
327
296
|
static RemoveSecurityTokenQuery() {
|
|
328
297
|
const params = new URLSearchParams(window.location.search);
|
|
329
|
-
|
|
330
298
|
if (params.has('securitytoken') || params.has('securityToken')) {
|
|
331
299
|
params.delete('securitytoken');
|
|
332
300
|
params.delete('securityToken');
|
|
333
301
|
window.location = `${window.location.pathname}${params.toString() ? `?${params}` : ''}`;
|
|
334
302
|
}
|
|
335
303
|
}
|
|
336
|
-
|
|
337
304
|
static async WsFedLogout(redirectPath) {
|
|
338
305
|
await fetch(`${LoginHelper.CMS_URL}/authenticate/logout?jsonResponseRequired=true`, {
|
|
339
306
|
credentials: 'include'
|
|
340
307
|
});
|
|
341
|
-
|
|
342
308
|
if (redirectPath) {
|
|
343
309
|
window.location = redirectPath;
|
|
344
310
|
} else {
|
|
@@ -347,7 +313,6 @@ class LoginHelper {
|
|
|
347
313
|
LoginHelper.RemoveSecurityTokenQuery();
|
|
348
314
|
}
|
|
349
315
|
}
|
|
350
|
-
|
|
351
316
|
static async GetCredentialsForSecurityToken(securityToken) {
|
|
352
317
|
const [error, response] = await to(fetch(`${LoginHelper.CMS_URL}/REST/Contensis/Security/IsAuthenticated`, {
|
|
353
318
|
method: 'POST',
|
|
@@ -362,7 +327,6 @@ class LoginHelper {
|
|
|
362
327
|
if (error) return [{
|
|
363
328
|
message: 'Failed to fetch credentials'
|
|
364
329
|
}];
|
|
365
|
-
|
|
366
330
|
if (response.ok) {
|
|
367
331
|
const [parseError, body] = await to(response.json());
|
|
368
332
|
if (parseError) return [parseError];
|
|
@@ -370,26 +334,22 @@ class LoginHelper {
|
|
|
370
334
|
LogonResult,
|
|
371
335
|
ApplicationData = []
|
|
372
336
|
} = body;
|
|
373
|
-
|
|
374
337
|
if (LogonResult !== 0) {
|
|
375
338
|
return [{
|
|
376
339
|
message: 'Security token is invalid',
|
|
377
340
|
data: ApplicationData
|
|
378
341
|
}];
|
|
379
342
|
}
|
|
380
|
-
|
|
381
343
|
if (ApplicationData.length > 0) {
|
|
382
344
|
let refreshToken;
|
|
383
345
|
ApplicationData.forEach(item => {
|
|
384
346
|
if (item.Key === 'ContensisSecurityRefreshToken') refreshToken = item.Value;
|
|
385
347
|
});
|
|
386
|
-
|
|
387
348
|
if (!refreshToken) {
|
|
388
349
|
return [{
|
|
389
350
|
message: 'Fetch credentials: Unable to find ContensisSecurityRefreshToken'
|
|
390
351
|
}];
|
|
391
352
|
}
|
|
392
|
-
|
|
393
353
|
return [undefined, refreshToken];
|
|
394
354
|
} else {
|
|
395
355
|
return [{
|
|
@@ -401,53 +361,50 @@ class LoginHelper {
|
|
|
401
361
|
message: `Fetch credentials error: ${response.status} ${response.statusText}`
|
|
402
362
|
}];
|
|
403
363
|
}
|
|
404
|
-
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// static isZengentiStaff(email) {
|
|
405
367
|
// const emailRefs = ['@zengenti', '@contensis'];
|
|
368
|
+
|
|
406
369
|
// return emailRefs.some(emailRef => {
|
|
407
370
|
// if (email.includes(emailRef)) {
|
|
408
371
|
// return true;
|
|
409
372
|
// }
|
|
410
373
|
// });
|
|
411
374
|
// }
|
|
412
|
-
|
|
413
|
-
|
|
414
375
|
}
|
|
415
|
-
LoginHelper.CMS_URL = SERVERS.cms
|
|
416
|
-
/* global
|
|
417
|
-
;
|
|
418
|
-
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
419
|
-
/* global WSFED_LOGIN */
|
|
420
|
-
: context.WSFED_LOGIN === 'true';
|
|
376
|
+
LoginHelper.CMS_URL = SERVERS.cms /* global SERVERS */;
|
|
377
|
+
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context.WSFED_LOGIN === 'true';
|
|
421
378
|
LoginHelper.LOGIN_ROUTE = '/account/login';
|
|
422
379
|
LoginHelper.ACCESS_DENIED_ROUTE = '/account/access-denied';
|
|
423
|
-
|
|
424
380
|
LoginHelper.GetUserDetails = async client => {
|
|
425
381
|
let userError,
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
382
|
+
groupsError,
|
|
383
|
+
user = {},
|
|
384
|
+
groupsResult;
|
|
429
385
|
[userError, user] = await to(client.security.users.getCurrent());
|
|
430
|
-
|
|
431
386
|
if (user && user.id) {
|
|
432
387
|
[groupsError, groupsResult] = await to(client.security.users.getUserGroups({
|
|
433
388
|
userId: user.id,
|
|
434
|
-
includeInherited: true
|
|
435
|
-
|
|
389
|
+
includeInherited: true,
|
|
390
|
+
pageOptions: {
|
|
391
|
+
pageSize: 100
|
|
392
|
+
}
|
|
393
|
+
}));
|
|
394
|
+
// Set groups attribute in user object to be the items
|
|
436
395
|
// array from the getUserGroups result
|
|
396
|
+
if (groupsResult && groupsResult.items) user.groups = groupsResult.items;
|
|
437
397
|
|
|
438
|
-
|
|
398
|
+
//If groups call fails then log the error but allow the user to login still
|
|
439
399
|
// eslint-disable-next-line no-console
|
|
440
|
-
|
|
441
400
|
if (groupsError) console.log(groupsError);
|
|
442
401
|
}
|
|
443
|
-
|
|
444
402
|
return [userError, user];
|
|
445
403
|
};
|
|
446
404
|
|
|
447
405
|
const loginSagas = [takeEvery(LOGIN_USER, loginUserSaga), takeEvery(LOGOUT_USER, logoutUserSaga), takeEvery(VALIDATE_USER, validateUserSaga), takeEvery(SET_AUTHENTICATION_STATE, redirectAfterSuccessfulLoginSaga)];
|
|
448
406
|
function* handleRequiresLoginSaga(action) {
|
|
449
407
|
var _entry$sys;
|
|
450
|
-
|
|
451
408
|
const {
|
|
452
409
|
entry,
|
|
453
410
|
requireLogin,
|
|
@@ -456,22 +413,24 @@ function* handleRequiresLoginSaga(action) {
|
|
|
456
413
|
},
|
|
457
414
|
staticRoute
|
|
458
415
|
} = action;
|
|
459
|
-
let userLoggedIn = yield select(selectUserIsAuthenticated);
|
|
416
|
+
let userLoggedIn = yield select(selectUserIsAuthenticated);
|
|
460
417
|
|
|
418
|
+
// Check for a securityToken in querystring
|
|
461
419
|
const currentQs = queryParams(yield select(selectCurrentSearch));
|
|
462
|
-
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
420
|
+
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
463
421
|
|
|
422
|
+
// Check if any of the defined routes have "requireLogin" attribute
|
|
464
423
|
const {
|
|
465
424
|
requireLogin: authRoute
|
|
466
425
|
} = staticRoute && staticRoute.route || {};
|
|
467
426
|
const {
|
|
468
427
|
requireLogin: authContentType
|
|
469
|
-
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 ? void 0 : (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
470
|
-
// array of groups we can merge all the arrays and match on any group supplied
|
|
428
|
+
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 ? void 0 : (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
471
429
|
|
|
430
|
+
// If requireLogin, authRoute or authContentType has been specified as an
|
|
431
|
+
// array of groups we can merge all the arrays and match on any group supplied
|
|
472
432
|
const routeRequiresGroups = [...(Array.isArray(authContentType) && authContentType || []), ...(Array.isArray(authRoute) && authRoute || []), ...(Array.isArray(requireLogin) && requireLogin || [])];
|
|
473
433
|
const routeRequiresLogin = !!authContentType || !!authRoute || !!requireLogin;
|
|
474
|
-
|
|
475
434
|
if (!userLoggedIn) {
|
|
476
435
|
// If cookies or securityToken are found on any route change
|
|
477
436
|
// always validate and login the user
|
|
@@ -480,13 +439,13 @@ function* handleRequiresLoginSaga(action) {
|
|
|
480
439
|
userLoggedIn = yield call(validateUserSaga, {
|
|
481
440
|
securityToken
|
|
482
441
|
});
|
|
483
|
-
}
|
|
442
|
+
}
|
|
443
|
+
// otherwise do a non blocking put to handle validation in the background
|
|
484
444
|
else yield put({
|
|
485
445
|
type: VALIDATE_USER,
|
|
486
446
|
securityToken
|
|
487
447
|
});
|
|
488
448
|
}
|
|
489
|
-
|
|
490
449
|
if (routeRequiresLogin) {
|
|
491
450
|
// If a security token is in the querystring and we are not already
|
|
492
451
|
// logged in something is wrong and we won't bother going on another redirect loop
|
|
@@ -499,13 +458,11 @@ function* handleRequiresLoginSaga(action) {
|
|
|
499
458
|
}
|
|
500
459
|
}
|
|
501
460
|
}
|
|
502
|
-
|
|
503
461
|
function* validateUserSaga({
|
|
504
462
|
securityToken
|
|
505
463
|
}) {
|
|
506
464
|
// Check for refreshToken in cookies
|
|
507
465
|
let clientCredentials = LoginHelper.GetCachedCredentials();
|
|
508
|
-
|
|
509
466
|
if (securityToken || clientCredentials.refreshToken) {
|
|
510
467
|
// We only attempt to validate the user if one of the stored
|
|
511
468
|
// tokens are found, in this case we set loading state manually
|
|
@@ -515,11 +472,10 @@ function* validateUserSaga({
|
|
|
515
472
|
authenticationState: {
|
|
516
473
|
isLoading: true
|
|
517
474
|
}
|
|
518
|
-
});
|
|
475
|
+
});
|
|
476
|
+
// If we have just a security token we will call a CMS endpoint
|
|
519
477
|
// and provide us with a RefreshToken cookie we can use during login
|
|
520
|
-
|
|
521
478
|
const [error, refreshToken] = yield LoginHelper.GetCredentialsForSecurityToken(securityToken);
|
|
522
|
-
|
|
523
479
|
if (refreshToken) {
|
|
524
480
|
// Set cookies and reload values
|
|
525
481
|
LoginHelper.SetLoginCookies({
|
|
@@ -527,9 +483,9 @@ function* validateUserSaga({
|
|
|
527
483
|
refreshToken
|
|
528
484
|
});
|
|
529
485
|
clientCredentials = LoginHelper.GetCachedCredentials();
|
|
530
|
-
}
|
|
531
|
-
|
|
486
|
+
}
|
|
532
487
|
|
|
488
|
+
// Log the user in if a refreshToken is found
|
|
533
489
|
if (clientCredentials.refreshToken) yield call(loginUserSaga, {
|
|
534
490
|
clientCredentials
|
|
535
491
|
});else if (error) yield put({
|
|
@@ -539,20 +495,20 @@ function* validateUserSaga({
|
|
|
539
495
|
errorMessage: (error === null || error === void 0 ? void 0 : error.message) || error && 'toString' in error && error.toString()
|
|
540
496
|
}
|
|
541
497
|
});
|
|
542
|
-
}
|
|
543
|
-
|
|
498
|
+
}
|
|
544
499
|
|
|
500
|
+
// Tell any callers have we successfully logged in?
|
|
545
501
|
return yield select(selectUserIsAuthenticated);
|
|
546
502
|
}
|
|
547
|
-
|
|
548
503
|
function* loginUserSaga(action = {}) {
|
|
549
504
|
const {
|
|
550
505
|
username,
|
|
551
506
|
password,
|
|
552
507
|
clientCredentials
|
|
553
|
-
} = action;
|
|
554
|
-
// just redirect them to the Identity Provider sign in
|
|
508
|
+
} = action;
|
|
555
509
|
|
|
510
|
+
// If a WSFED_LOGIN site has dispatched the loginUser action
|
|
511
|
+
// just redirect them to the Identity Provider sign in
|
|
556
512
|
if (action.type === LOGIN_USER && LoginHelper.WSFED_LOGIN) LoginHelper.ClientRedirectToSignInPage();
|
|
557
513
|
const {
|
|
558
514
|
authenticationState,
|
|
@@ -568,33 +524,30 @@ function* loginUserSaga(action = {}) {
|
|
|
568
524
|
user
|
|
569
525
|
});
|
|
570
526
|
}
|
|
571
|
-
|
|
572
527
|
const removeHostnamePart = path => {
|
|
573
528
|
// eslint-disable-next-line no-console
|
|
574
529
|
console.log(path);
|
|
575
|
-
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
576
|
-
|
|
530
|
+
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
531
|
+
// eslint-disable-next-line no-console
|
|
577
532
|
console.log(relativePath);
|
|
578
533
|
return relativePath;
|
|
579
534
|
};
|
|
580
|
-
|
|
581
535
|
function* redirectAfterSuccessfulLoginSaga() {
|
|
582
536
|
const isLoggedIn = yield select(selectUserIsAuthenticated);
|
|
583
537
|
const {
|
|
584
538
|
redirect_uri: redirectPath,
|
|
585
539
|
ReturnURL: assetRedirectPath
|
|
586
540
|
} = queryParams(yield select(selectCurrentSearch));
|
|
587
|
-
|
|
588
541
|
if (isLoggedIn && assetRedirectPath && typeof window != 'undefined') {
|
|
589
|
-
const path = removeHostnamePart(assetRedirectPath);
|
|
542
|
+
const path = removeHostnamePart(assetRedirectPath);
|
|
543
|
+
// This has to be a hard href to get the app to
|
|
590
544
|
// leave React and hit the server for the IIS hosted assets
|
|
591
|
-
|
|
592
|
-
|
|
545
|
+
window.location.href = path;
|
|
546
|
+
// yield put(setRoute(path)); // does not work in this scenario
|
|
593
547
|
} else if (isLoggedIn && redirectPath) {
|
|
594
548
|
yield put(setRoute(redirectPath));
|
|
595
549
|
}
|
|
596
550
|
}
|
|
597
|
-
|
|
598
551
|
function* logoutUserSaga({
|
|
599
552
|
redirectPath
|
|
600
553
|
}) {
|
|
@@ -604,10 +557,8 @@ function* logoutUserSaga({
|
|
|
604
557
|
});
|
|
605
558
|
yield LoginHelper.LogoutUser(redirectPath);
|
|
606
559
|
}
|
|
607
|
-
|
|
608
560
|
function* refreshSecurityToken() {
|
|
609
561
|
const clientCredentials = yield select(selectClientCredentials, 'js');
|
|
610
|
-
|
|
611
562
|
if (Object.keys(clientCredentials).length > 0) {
|
|
612
563
|
const client = yield getManagementApiClient(clientCredentials);
|
|
613
564
|
yield client.authenticate();
|
|
@@ -621,4 +572,4 @@ function* refreshSecurityToken() {
|
|
|
621
572
|
}
|
|
622
573
|
|
|
623
574
|
export { LoginHelper as L, findContentTypeMapping as f, getManagementApiClient as g, handleRequiresLoginSaga as h, loginSagas as l, refreshSecurityToken as r };
|
|
624
|
-
//# sourceMappingURL=login-
|
|
575
|
+
//# sourceMappingURL=login-71ff3fcb.js.map
|