@zengenti/contensis-react-base 3.0.2-beta.4 → 3.0.2-beta.6
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-a2783f8b.js → App-2a7a16ad.js} +110 -429
- package/cjs/App-2a7a16ad.js.map +1 -0
- package/cjs/ContensisDeliveryApi-de88df2a.js +231 -0
- package/cjs/ContensisDeliveryApi-de88df2a.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-47d70a26.js} +23 -37
- package/{esm/RouteLoader-5171c63f.js.map → cjs/RouteLoader-47d70a26.js.map} +1 -1
- package/cjs/{ToJs-a9a8522b.js → ToJs-61c03582.js} +3 -4
- package/cjs/{ToJs-a9a8522b.js.map → ToJs-61c03582.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 +11 -153
- 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-e711a19e.js → login-2ea569cc.js} +60 -112
- package/cjs/{login-e711a19e.js.map → login-2ea569cc.js.map} +1 -1
- package/cjs/{reducers-73a03ef4.js → reducers-9afb5f89.js} +10 -31
- package/{esm/reducers-aa8cef1e.js.map → cjs/reducers-9afb5f89.js.map} +1 -1
- 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-6d12e7ca.js} +182 -282
- package/{esm/sagas-e576b6f6.js.map → cjs/sagas-6d12e7ca.js.map} +1 -1
- package/cjs/search.js +56 -82
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-656da4b7.js → selectors-c76c2676.js} +84 -7
- package/cjs/selectors-c76c2676.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-bf9ef45e.js → version-38afaf2a.js} +45 -158
- package/cjs/version-38afaf2a.js.map +1 -0
- package/cjs/version-886f49d8.js +98 -0
- package/cjs/version-886f49d8.js.map +1 -0
- package/esm/{App-17d1ac3c.js → App-4fb1fc44.js} +92 -409
- package/esm/App-4fb1fc44.js.map +1 -0
- package/esm/ContensisDeliveryApi-ad06857d.js +227 -0
- package/esm/ContensisDeliveryApi-ad06857d.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-f5d5f733.js} +22 -36
- package/{cjs/RouteLoader-3aa6456e.js.map → esm/RouteLoader-f5d5f733.js.map} +1 -1
- package/esm/{ToJs-4e02a04d.js → ToJs-0066e629.js} +3 -4
- package/esm/{ToJs-4e02a04d.js.map → ToJs-0066e629.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 +11 -153
- 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-551d243a.js → login-bffb081f.js} +59 -111
- package/esm/{login-551d243a.js.map → login-bffb081f.js.map} +1 -1
- package/esm/{reducers-aa8cef1e.js → reducers-3d5c37d1.js} +10 -31
- package/{cjs/reducers-73a03ef4.js.map → esm/reducers-3d5c37d1.js.map} +1 -1
- 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-53d2aefb.js} +134 -235
- package/{cjs/sagas-8a20e424.js.map → esm/sagas-53d2aefb.js.map} +1 -1
- package/esm/search.js +57 -83
- package/esm/search.js.map +1 -1
- package/esm/{selectors-a5e5835b.js → selectors-3f0d804d.js} +70 -7
- package/esm/selectors-3f0d804d.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-72ca17f3.js → version-dd31c7f0.js} +32 -141
- package/esm/version-dd31c7f0.js.map +1 -0
- package/esm/version-f4629693.js +87 -0
- package/esm/version-f4629693.js.map +1 -0
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/models/util/ContensisDeliveryApi.d.ts +6 -0
- package/models/util/index.d.ts +1 -0
- package/package.json +2 -2
- package/cjs/App-a2783f8b.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/selectors-656da4b7.js.map +0 -1
- package/cjs/version-bf9ef45e.js.map +0 -1
- package/cjs/version-eba6d09b.js +0 -20
- package/cjs/version-eba6d09b.js.map +0 -1
- package/esm/App-17d1ac3c.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.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-72ca17f3.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-0066e629.js';
|
|
4
|
+
import { q as queryParams, o as selectCurrentSearch, p as setRoute } from './selectors-3f0d804d.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,47 @@ 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
389
|
includeInherited: true
|
|
435
|
-
}));
|
|
390
|
+
}));
|
|
391
|
+
// Set groups attribute in user object to be the items
|
|
436
392
|
// array from the getUserGroups result
|
|
393
|
+
if (groupsResult && groupsResult.items) user.groups = groupsResult.items;
|
|
437
394
|
|
|
438
|
-
|
|
395
|
+
//If groups call fails then log the error but allow the user to login still
|
|
439
396
|
// eslint-disable-next-line no-console
|
|
440
|
-
|
|
441
397
|
if (groupsError) console.log(groupsError);
|
|
442
398
|
}
|
|
443
|
-
|
|
444
399
|
return [userError, user];
|
|
445
400
|
};
|
|
446
401
|
|
|
447
402
|
const loginSagas = [takeEvery(LOGIN_USER, loginUserSaga), takeEvery(LOGOUT_USER, logoutUserSaga), takeEvery(VALIDATE_USER, validateUserSaga), takeEvery(SET_AUTHENTICATION_STATE, redirectAfterSuccessfulLoginSaga)];
|
|
448
403
|
function* handleRequiresLoginSaga(action) {
|
|
449
404
|
var _entry$sys;
|
|
450
|
-
|
|
451
405
|
const {
|
|
452
406
|
entry,
|
|
453
407
|
requireLogin,
|
|
@@ -456,22 +410,24 @@ function* handleRequiresLoginSaga(action) {
|
|
|
456
410
|
},
|
|
457
411
|
staticRoute
|
|
458
412
|
} = action;
|
|
459
|
-
let userLoggedIn = yield select(selectUserIsAuthenticated);
|
|
413
|
+
let userLoggedIn = yield select(selectUserIsAuthenticated);
|
|
460
414
|
|
|
415
|
+
// Check for a securityToken in querystring
|
|
461
416
|
const currentQs = queryParams(yield select(selectCurrentSearch));
|
|
462
|
-
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
417
|
+
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
463
418
|
|
|
419
|
+
// Check if any of the defined routes have "requireLogin" attribute
|
|
464
420
|
const {
|
|
465
421
|
requireLogin: authRoute
|
|
466
422
|
} = staticRoute && staticRoute.route || {};
|
|
467
423
|
const {
|
|
468
424
|
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
|
|
425
|
+
} = 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
426
|
|
|
427
|
+
// If requireLogin, authRoute or authContentType has been specified as an
|
|
428
|
+
// array of groups we can merge all the arrays and match on any group supplied
|
|
472
429
|
const routeRequiresGroups = [...(Array.isArray(authContentType) && authContentType || []), ...(Array.isArray(authRoute) && authRoute || []), ...(Array.isArray(requireLogin) && requireLogin || [])];
|
|
473
430
|
const routeRequiresLogin = !!authContentType || !!authRoute || !!requireLogin;
|
|
474
|
-
|
|
475
431
|
if (!userLoggedIn) {
|
|
476
432
|
// If cookies or securityToken are found on any route change
|
|
477
433
|
// always validate and login the user
|
|
@@ -480,13 +436,13 @@ function* handleRequiresLoginSaga(action) {
|
|
|
480
436
|
userLoggedIn = yield call(validateUserSaga, {
|
|
481
437
|
securityToken
|
|
482
438
|
});
|
|
483
|
-
}
|
|
439
|
+
}
|
|
440
|
+
// otherwise do a non blocking put to handle validation in the background
|
|
484
441
|
else yield put({
|
|
485
442
|
type: VALIDATE_USER,
|
|
486
443
|
securityToken
|
|
487
444
|
});
|
|
488
445
|
}
|
|
489
|
-
|
|
490
446
|
if (routeRequiresLogin) {
|
|
491
447
|
// If a security token is in the querystring and we are not already
|
|
492
448
|
// logged in something is wrong and we won't bother going on another redirect loop
|
|
@@ -499,13 +455,11 @@ function* handleRequiresLoginSaga(action) {
|
|
|
499
455
|
}
|
|
500
456
|
}
|
|
501
457
|
}
|
|
502
|
-
|
|
503
458
|
function* validateUserSaga({
|
|
504
459
|
securityToken
|
|
505
460
|
}) {
|
|
506
461
|
// Check for refreshToken in cookies
|
|
507
462
|
let clientCredentials = LoginHelper.GetCachedCredentials();
|
|
508
|
-
|
|
509
463
|
if (securityToken || clientCredentials.refreshToken) {
|
|
510
464
|
// We only attempt to validate the user if one of the stored
|
|
511
465
|
// tokens are found, in this case we set loading state manually
|
|
@@ -515,11 +469,10 @@ function* validateUserSaga({
|
|
|
515
469
|
authenticationState: {
|
|
516
470
|
isLoading: true
|
|
517
471
|
}
|
|
518
|
-
});
|
|
472
|
+
});
|
|
473
|
+
// If we have just a security token we will call a CMS endpoint
|
|
519
474
|
// and provide us with a RefreshToken cookie we can use during login
|
|
520
|
-
|
|
521
475
|
const [error, refreshToken] = yield LoginHelper.GetCredentialsForSecurityToken(securityToken);
|
|
522
|
-
|
|
523
476
|
if (refreshToken) {
|
|
524
477
|
// Set cookies and reload values
|
|
525
478
|
LoginHelper.SetLoginCookies({
|
|
@@ -527,9 +480,9 @@ function* validateUserSaga({
|
|
|
527
480
|
refreshToken
|
|
528
481
|
});
|
|
529
482
|
clientCredentials = LoginHelper.GetCachedCredentials();
|
|
530
|
-
}
|
|
531
|
-
|
|
483
|
+
}
|
|
532
484
|
|
|
485
|
+
// Log the user in if a refreshToken is found
|
|
533
486
|
if (clientCredentials.refreshToken) yield call(loginUserSaga, {
|
|
534
487
|
clientCredentials
|
|
535
488
|
});else if (error) yield put({
|
|
@@ -539,20 +492,20 @@ function* validateUserSaga({
|
|
|
539
492
|
errorMessage: (error === null || error === void 0 ? void 0 : error.message) || error && 'toString' in error && error.toString()
|
|
540
493
|
}
|
|
541
494
|
});
|
|
542
|
-
}
|
|
543
|
-
|
|
495
|
+
}
|
|
544
496
|
|
|
497
|
+
// Tell any callers have we successfully logged in?
|
|
545
498
|
return yield select(selectUserIsAuthenticated);
|
|
546
499
|
}
|
|
547
|
-
|
|
548
500
|
function* loginUserSaga(action = {}) {
|
|
549
501
|
const {
|
|
550
502
|
username,
|
|
551
503
|
password,
|
|
552
504
|
clientCredentials
|
|
553
|
-
} = action;
|
|
554
|
-
// just redirect them to the Identity Provider sign in
|
|
505
|
+
} = action;
|
|
555
506
|
|
|
507
|
+
// If a WSFED_LOGIN site has dispatched the loginUser action
|
|
508
|
+
// just redirect them to the Identity Provider sign in
|
|
556
509
|
if (action.type === LOGIN_USER && LoginHelper.WSFED_LOGIN) LoginHelper.ClientRedirectToSignInPage();
|
|
557
510
|
const {
|
|
558
511
|
authenticationState,
|
|
@@ -568,33 +521,30 @@ function* loginUserSaga(action = {}) {
|
|
|
568
521
|
user
|
|
569
522
|
});
|
|
570
523
|
}
|
|
571
|
-
|
|
572
524
|
const removeHostnamePart = path => {
|
|
573
525
|
// eslint-disable-next-line no-console
|
|
574
526
|
console.log(path);
|
|
575
|
-
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
576
|
-
|
|
527
|
+
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
528
|
+
// eslint-disable-next-line no-console
|
|
577
529
|
console.log(relativePath);
|
|
578
530
|
return relativePath;
|
|
579
531
|
};
|
|
580
|
-
|
|
581
532
|
function* redirectAfterSuccessfulLoginSaga() {
|
|
582
533
|
const isLoggedIn = yield select(selectUserIsAuthenticated);
|
|
583
534
|
const {
|
|
584
535
|
redirect_uri: redirectPath,
|
|
585
536
|
ReturnURL: assetRedirectPath
|
|
586
537
|
} = queryParams(yield select(selectCurrentSearch));
|
|
587
|
-
|
|
588
538
|
if (isLoggedIn && assetRedirectPath && typeof window != 'undefined') {
|
|
589
|
-
const path = removeHostnamePart(assetRedirectPath);
|
|
539
|
+
const path = removeHostnamePart(assetRedirectPath);
|
|
540
|
+
// This has to be a hard href to get the app to
|
|
590
541
|
// leave React and hit the server for the IIS hosted assets
|
|
591
|
-
|
|
592
|
-
|
|
542
|
+
window.location.href = path;
|
|
543
|
+
// yield put(setRoute(path)); // does not work in this scenario
|
|
593
544
|
} else if (isLoggedIn && redirectPath) {
|
|
594
545
|
yield put(setRoute(redirectPath));
|
|
595
546
|
}
|
|
596
547
|
}
|
|
597
|
-
|
|
598
548
|
function* logoutUserSaga({
|
|
599
549
|
redirectPath
|
|
600
550
|
}) {
|
|
@@ -604,10 +554,8 @@ function* logoutUserSaga({
|
|
|
604
554
|
});
|
|
605
555
|
yield LoginHelper.LogoutUser(redirectPath);
|
|
606
556
|
}
|
|
607
|
-
|
|
608
557
|
function* refreshSecurityToken() {
|
|
609
558
|
const clientCredentials = yield select(selectClientCredentials, 'js');
|
|
610
|
-
|
|
611
559
|
if (Object.keys(clientCredentials).length > 0) {
|
|
612
560
|
const client = yield getManagementApiClient(clientCredentials);
|
|
613
561
|
yield client.authenticate();
|
|
@@ -621,4 +569,4 @@ function* refreshSecurityToken() {
|
|
|
621
569
|
}
|
|
622
570
|
|
|
623
571
|
export { LoginHelper as L, findContentTypeMapping as f, getManagementApiClient as g, handleRequiresLoginSaga as h, loginSagas as l, refreshSecurityToken as r };
|
|
624
|
-
//# sourceMappingURL=login-
|
|
572
|
+
//# sourceMappingURL=login-bffb081f.js.map
|