@zengenti/contensis-react-base 3.0.2-beta.9 → 3.1.1-beta.0
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/README.md +38 -2
- package/cjs/{App-81a45001.js → App-555eebb0.js} +70 -34
- package/cjs/App-555eebb0.js.map +1 -0
- package/cjs/{login-51b66359.js → ChangePassword.container-f3f94d8f.js} +246 -84
- package/cjs/ChangePassword.container-f3f94d8f.js.map +1 -0
- package/cjs/{ContensisDeliveryApi-de88df2a.js → ContensisDeliveryApi-ea5ffdc2.js} +162 -122
- package/cjs/ContensisDeliveryApi-ea5ffdc2.js.map +1 -0
- package/cjs/CookieConstants-000427db.js +10 -0
- package/cjs/CookieConstants-000427db.js.map +1 -0
- package/cjs/{RouteLoader-47d70a26.js → RouteLoader-014a95b9.js} +8 -5
- package/cjs/RouteLoader-014a95b9.js.map +1 -0
- package/cjs/{ToJs-61c03582.js → ToJs-64970869.js} +49 -2
- package/cjs/ToJs-64970869.js.map +1 -0
- package/cjs/_commonjsHelpers-b3309d7b.js +11 -0
- package/cjs/_commonjsHelpers-b3309d7b.js.map +1 -0
- package/cjs/client.js +14 -12
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +47 -361
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +3495 -127
- package/cjs/forms.js.map +1 -1
- package/cjs/redux.js +3 -4
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +4 -3
- package/cjs/routing.js.map +1 -1
- package/cjs/{sagas-6d12e7ca.js → sagas-e04b94c1.js} +44 -20
- package/cjs/sagas-e04b94c1.js.map +1 -0
- package/cjs/search.js +13 -13
- package/cjs/search.js.map +1 -1
- package/cjs/{selectors-c76c2676.js → selectors-8e56cc34.js} +14 -13
- package/cjs/selectors-8e56cc34.js.map +1 -0
- package/cjs/user.js +33 -159
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +6 -4
- package/cjs/util.js.map +1 -1
- package/cjs/{version-886f49d8.js → version-91b90ee8.js} +3 -3
- package/cjs/{version-886f49d8.js.map → version-91b90ee8.js.map} +1 -1
- package/cjs/{version-38afaf2a.js → version-fb4ba30b.js} +16 -24
- package/cjs/version-fb4ba30b.js.map +1 -0
- package/esm/{App-5f914483.js → App-aaea6310.js} +64 -29
- package/esm/App-aaea6310.js.map +1 -0
- package/esm/{login-4d07c2de.js → ChangePassword.container-724c8e0a.js} +229 -78
- package/esm/ChangePassword.container-724c8e0a.js.map +1 -0
- package/esm/ContensisDeliveryApi-fe53fa10.js +265 -0
- package/esm/ContensisDeliveryApi-fe53fa10.js.map +1 -0
- package/esm/CookieConstants-3d3b6531.js +6 -0
- package/esm/CookieConstants-3d3b6531.js.map +1 -0
- package/esm/{RouteLoader-f5d5f733.js → RouteLoader-fe64ca81.js} +8 -5
- package/esm/RouteLoader-fe64ca81.js.map +1 -0
- package/esm/{ToJs-0066e629.js → ToJs-c75473e9.js} +49 -3
- package/esm/ToJs-c75473e9.js.map +1 -0
- package/esm/_commonjsHelpers-1789f0cf.js +8 -0
- package/esm/_commonjsHelpers-1789f0cf.js.map +1 -0
- package/esm/client.js +15 -13
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +46 -361
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +3497 -129
- package/esm/forms.js.map +1 -1
- package/esm/redux.js +6 -7
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +4 -3
- package/esm/routing.js.map +1 -1
- package/esm/{sagas-53d2aefb.js → sagas-933a8fc8.js} +44 -20
- package/esm/sagas-933a8fc8.js.map +1 -0
- package/esm/search.js +14 -14
- package/esm/search.js.map +1 -1
- package/esm/{selectors-3f0d804d.js → selectors-0fe67d47.js} +14 -14
- package/esm/selectors-0fe67d47.js.map +1 -0
- package/esm/user.js +21 -151
- package/esm/user.js.map +1 -1
- package/esm/util.js +4 -4
- package/esm/{version-dd31c7f0.js → version-7ea8bea8.js} +17 -24
- package/esm/version-7ea8bea8.js.map +1 -0
- package/esm/{version-f4629693.js → version-f42f7bdc.js} +3 -3
- package/esm/{version-f4629693.js.map → version-f42f7bdc.js.map} +1 -1
- package/models/client/client.d.ts +1 -1
- package/models/config.d.ts +4 -4
- package/models/redux/appstate.d.ts +2 -1
- package/models/routing/redux/actions.d.ts +10 -6
- package/models/routing/redux/selectors.d.ts +5 -4
- package/models/routing/redux/types.d.ts +0 -1
- package/models/routing/routes.d.ts +20 -17
- package/models/routing/util/queries.d.ts +3 -2
- package/models/search/models/Queries.d.ts +9 -10
- package/models/search/models/Search.d.ts +26 -24
- package/models/search/models/SearchActions.d.ts +36 -36
- package/models/search/models/SearchState.d.ts +11 -11
- package/models/search/models/SearchUtil.d.ts +1 -1
- package/models/search/models/WithSearch.d.ts +1 -1
- package/models/search/redux/actions.d.ts +7 -7
- package/models/search/redux/selectors.d.ts +27 -27
- package/models/search/redux/types.d.ts +21 -21
- package/models/search/redux/util.d.ts +2 -2
- package/models/search/search/ContensisDeliveryApi.d.ts +1 -1
- package/models/search/search/expressions.d.ts +4 -4
- package/models/search/search/util.d.ts +2 -2
- package/models/search/transformations/state-to-queryparams.mapper.d.ts +1 -1
- package/models/server/features/linkdepth-api/LinkDepthSearchService.d.ts +1 -1
- package/models/server/features/linkdepth-api/search.d.ts +3 -3
- package/models/server/internalServer.d.ts +7 -5
- package/models/server/util/bundles.d.ts +2 -2
- package/models/server/util/handleExceptions.d.ts +1 -1
- package/models/testImmer/redux/reducer.d.ts +1 -1
- package/models/user/components/Login.d.ts +2 -3
- package/models/user/containers/ChangePassword.container.d.ts +2 -2
- package/models/user/containers/ForgotPassword.container.d.ts +2 -2
- package/models/user/containers/Login.container.d.ts +2 -2
- package/models/user/containers/Registration.container.d.ts +2 -2
- package/models/user/hocs/withLogin.d.ts +5 -11
- package/models/user/hocs/withRegistration.d.ts +2 -8
- package/models/user/redux/actions.d.ts +2 -2
- package/models/user/redux/sagas/login.d.ts +9 -8
- package/models/user/redux/selectors.d.ts +4 -4
- package/models/user/util/CookieConstants.d.ts +8 -0
- package/models/user/util/CookieHelper.class.d.ts +15 -3
- package/models/user/util/LoginHelper.class.d.ts +27 -23
- package/models/util/CachedDeliveryApi.d.ts +25 -0
- package/models/util/ContensisDeliveryApi.d.ts +20 -44
- package/models/util/LruCache.d.ts +12 -0
- package/models/util/ToJs.d.ts +1 -1
- package/models/util/index.d.ts +1 -1
- package/models/util/json-mapper.d.ts +1 -1
- package/package.json +10 -11
- package/cjs/App-81a45001.js.map +0 -1
- package/cjs/ContensisDeliveryApi-de88df2a.js.map +0 -1
- package/cjs/RouteLoader-47d70a26.js.map +0 -1
- package/cjs/ToJs-61c03582.js.map +0 -1
- package/cjs/login-51b66359.js.map +0 -1
- package/cjs/sagas-6d12e7ca.js.map +0 -1
- package/cjs/selectors-c76c2676.js.map +0 -1
- package/cjs/version-38afaf2a.js.map +0 -1
- package/esm/App-5f914483.js.map +0 -1
- package/esm/ContensisDeliveryApi-ad06857d.js +0 -227
- package/esm/ContensisDeliveryApi-ad06857d.js.map +0 -1
- package/esm/RouteLoader-f5d5f733.js.map +0 -1
- package/esm/ToJs-0066e629.js.map +0 -1
- package/esm/login-4d07c2de.js.map +0 -1
- package/esm/sagas-53d2aefb.js.map +0 -1
- package/esm/selectors-3f0d804d.js.map +0 -1
- package/esm/version-dd31c7f0.js.map +0 -1
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var effects = require('@redux-saga/core/effects');
|
|
4
4
|
var reducers = require('./reducers-9afb5f89.js');
|
|
5
|
-
var ToJs = require('./ToJs-
|
|
6
|
-
var selectors = require('./selectors-
|
|
5
|
+
var ToJs = require('./ToJs-64970869.js');
|
|
6
|
+
var selectors = require('./selectors-8e56cc34.js');
|
|
7
7
|
var mapJson = require('jsonpath-mapper');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
8
|
+
var to = require('await-to-js');
|
|
9
|
+
var CookieConstants = require('./CookieConstants-000427db.js');
|
|
10
|
+
var reactCookie = require('react-cookie');
|
|
11
|
+
var reactRedux = require('react-redux');
|
|
10
12
|
|
|
11
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
14
|
|
|
@@ -29,7 +31,6 @@ function _interopNamespace(e) {
|
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
var mapJson__default = /*#__PURE__*/_interopDefaultLegacy(mapJson);
|
|
32
|
-
var JSCookie__default = /*#__PURE__*/_interopDefaultLegacy(JSCookie);
|
|
33
34
|
|
|
34
35
|
const findContentTypeMapping = (ContentTypeMappings, contentTypeId) => ContentTypeMappings.find(ct => ct.contentTypeID === contentTypeId);
|
|
35
36
|
|
|
@@ -77,9 +78,15 @@ const getManagementApiClient = async ({
|
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
let {
|
|
81
82
|
Client
|
|
82
83
|
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('contensis-management-api')); });
|
|
84
|
+
if (typeof window === 'undefined') {
|
|
85
|
+
const {
|
|
86
|
+
UniversalClient
|
|
87
|
+
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('contensis-management-api')); });
|
|
88
|
+
Client = UniversalClient;
|
|
89
|
+
}
|
|
83
90
|
const client = Client.create({
|
|
84
91
|
...config,
|
|
85
92
|
projectId,
|
|
@@ -93,32 +100,6 @@ const getManagementApiClient = async ({
|
|
|
93
100
|
return client;
|
|
94
101
|
};
|
|
95
102
|
|
|
96
|
-
const COOKIE_VALID_DAYS = 1; // 0 = Session cookie
|
|
97
|
-
|
|
98
|
-
// Override the default js-cookie conversion / encoding
|
|
99
|
-
// methods so the written values work with Contensis sites
|
|
100
|
-
const Cookies = JSCookie__default["default"].withConverter({
|
|
101
|
-
read: value => decodeURIComponent(value),
|
|
102
|
-
write: value => encodeURIComponent(value)
|
|
103
|
-
});
|
|
104
|
-
class CookieHelper {
|
|
105
|
-
static GetCookie(name) {
|
|
106
|
-
const cookie = Cookies.get(name);
|
|
107
|
-
if (typeof cookie === 'undefined') {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
return cookie;
|
|
111
|
-
}
|
|
112
|
-
static SetCookie(name, value, maxAgeDays = COOKIE_VALID_DAYS) {
|
|
113
|
-
if (maxAgeDays === 0) Cookies.set(name, value);else Cookies.set(name, value, {
|
|
114
|
-
expires: maxAgeDays
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
static DeleteCookie(name) {
|
|
118
|
-
Cookies.remove(name);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
103
|
const context$1 = typeof window != 'undefined' ? window : global;
|
|
123
104
|
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context$1.WSFED_LOGIN === 'true';
|
|
124
105
|
const servers = SERVERS; /* global SERVERS */
|
|
@@ -146,30 +127,32 @@ const createUserManager = async config => {
|
|
|
146
127
|
};
|
|
147
128
|
|
|
148
129
|
/* eslint-disable require-atomic-updates */
|
|
149
|
-
const LOGIN_COOKIE = 'ContensisCMSUserName';
|
|
150
|
-
const REFRESH_TOKEN_COOKIE = 'RefreshToken';
|
|
151
130
|
const context = typeof window != 'undefined' ? window : global;
|
|
152
131
|
class LoginHelper {
|
|
153
|
-
|
|
132
|
+
constructor(cookies) {
|
|
133
|
+
this.cookies = void 0;
|
|
134
|
+
this.cookies = cookies;
|
|
135
|
+
}
|
|
136
|
+
SetLoginCookies({
|
|
154
137
|
contensisClassicToken,
|
|
155
138
|
refreshToken
|
|
156
139
|
}) {
|
|
157
|
-
console.info('SetLoginCookies:', LOGIN_COOKIE, contensisClassicToken, REFRESH_TOKEN_COOKIE, refreshToken);
|
|
158
|
-
if (contensisClassicToken)
|
|
159
|
-
if (refreshToken)
|
|
140
|
+
console.info('SetLoginCookies:', CookieConstants.LOGIN_COOKIE, contensisClassicToken, CookieConstants.REFRESH_TOKEN_COOKIE, refreshToken);
|
|
141
|
+
if (contensisClassicToken) this.cookies.SetCookie(CookieConstants.LOGIN_COOKIE, contensisClassicToken);
|
|
142
|
+
if (refreshToken) this.cookies.SetCookie(CookieConstants.REFRESH_TOKEN_COOKIE, refreshToken);
|
|
160
143
|
}
|
|
161
|
-
|
|
144
|
+
GetCachedCredentials() {
|
|
162
145
|
return {
|
|
163
146
|
bearerToken: null,
|
|
164
147
|
bearerTokenExpiryDate: null,
|
|
165
|
-
refreshToken:
|
|
148
|
+
refreshToken: this.cookies.GetCookie(CookieConstants.REFRESH_TOKEN_COOKIE),
|
|
166
149
|
refreshTokenExpiryDate: null,
|
|
167
|
-
contensisClassicToken:
|
|
150
|
+
contensisClassicToken: this.cookies.GetCookie(CookieConstants.LOGIN_COOKIE)
|
|
168
151
|
};
|
|
169
152
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
153
|
+
ClearCachedCredentials() {
|
|
154
|
+
this.cookies.DeleteCookie(CookieConstants.LOGIN_COOKIE);
|
|
155
|
+
this.cookies.DeleteCookie(CookieConstants.REFRESH_TOKEN_COOKIE);
|
|
173
156
|
if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
|
|
174
157
|
// remove any oidc keys left over in localStorage
|
|
175
158
|
const {
|
|
@@ -183,7 +166,7 @@ class LoginHelper {
|
|
|
183
166
|
keys.forEach(key => localStorage.removeItem(key));
|
|
184
167
|
}
|
|
185
168
|
}
|
|
186
|
-
|
|
169
|
+
async LoginUser({
|
|
187
170
|
username,
|
|
188
171
|
password,
|
|
189
172
|
clientCredentials
|
|
@@ -205,7 +188,7 @@ class LoginHelper {
|
|
|
205
188
|
});
|
|
206
189
|
|
|
207
190
|
// Ensure the client has requested a bearer token
|
|
208
|
-
const [loginError, clientBearerToken] = await
|
|
191
|
+
const [loginError, clientBearerToken] = await to.to(transientClient.ensureBearerToken());
|
|
209
192
|
|
|
210
193
|
// Problem getting token with username and password
|
|
211
194
|
if (loginError) {
|
|
@@ -216,14 +199,14 @@ class LoginHelper {
|
|
|
216
199
|
isAuthenticationError: loginError.name.includes('ContensisAuthenticationError'),
|
|
217
200
|
isError: true
|
|
218
201
|
};
|
|
219
|
-
|
|
202
|
+
this.ClearCachedCredentials();
|
|
220
203
|
}
|
|
221
204
|
|
|
222
205
|
// Got a token using username and password
|
|
223
206
|
if (clientBearerToken) {
|
|
224
207
|
// Set credentials so we can continue to GetUserDetails
|
|
225
208
|
credentials = mapClientCredentials(transientClient);
|
|
226
|
-
|
|
209
|
+
this.SetLoginCookies(credentials);
|
|
227
210
|
authenticationState = {
|
|
228
211
|
clientCredentials: credentials,
|
|
229
212
|
isAuthenticated: true,
|
|
@@ -247,11 +230,11 @@ class LoginHelper {
|
|
|
247
230
|
isAuthenticationError: false,
|
|
248
231
|
isError: true
|
|
249
232
|
};
|
|
250
|
-
|
|
233
|
+
this.ClearCachedCredentials();
|
|
251
234
|
} else {
|
|
252
235
|
// Ensure we get latest refreshToken and contensisClassicToken from the latest client
|
|
253
236
|
const latestCredentials = mapClientCredentials(client);
|
|
254
|
-
|
|
237
|
+
this.SetLoginCookies(latestCredentials);
|
|
255
238
|
user = userDetails;
|
|
256
239
|
authenticationState = {
|
|
257
240
|
clientCredentials: latestCredentials,
|
|
@@ -266,8 +249,8 @@ class LoginHelper {
|
|
|
266
249
|
user
|
|
267
250
|
};
|
|
268
251
|
}
|
|
269
|
-
|
|
270
|
-
|
|
252
|
+
LogoutUser(redirectPath) {
|
|
253
|
+
this.ClearCachedCredentials();
|
|
271
254
|
if (LoginHelper.WSFED_LOGIN) {
|
|
272
255
|
LoginHelper.WsFedLogout(redirectPath);
|
|
273
256
|
} else {
|
|
@@ -289,6 +272,7 @@ class LoginHelper {
|
|
|
289
272
|
}
|
|
290
273
|
}
|
|
291
274
|
static async ClientRedirectToSignInPage(redirectPath) {
|
|
275
|
+
if (typeof location === 'undefined') return;
|
|
292
276
|
if (LoginHelper.WSFED_LOGIN) {
|
|
293
277
|
await LoginHelper.WsFedLogout();
|
|
294
278
|
await LoginHelper.WsFedLogin();
|
|
@@ -299,11 +283,13 @@ class LoginHelper {
|
|
|
299
283
|
if (typeof location !== 'undefined' && redirectPath !== LoginHelper.LOGIN_ROUTE) location.replace(url);
|
|
300
284
|
}
|
|
301
285
|
}
|
|
302
|
-
static
|
|
286
|
+
static GetAccessDeniedRoute(originalPath) {
|
|
303
287
|
let url = LoginHelper.ACCESS_DENIED_ROUTE;
|
|
304
|
-
if (originalPath ===
|
|
305
|
-
|
|
306
|
-
|
|
288
|
+
if (originalPath !== url && typeof originalPath === 'string') url = `${url}?original_uri=${originalPath}`;
|
|
289
|
+
return url;
|
|
290
|
+
}
|
|
291
|
+
static ClientRedirectToAccessDeniedPage(originalPath) {
|
|
292
|
+
if (typeof location !== 'undefined') location.href = LoginHelper.GetAccessDeniedRoute(originalPath);
|
|
307
293
|
}
|
|
308
294
|
static ClientRedirectToPath(redirectPath) {
|
|
309
295
|
if (typeof redirectPath === 'string') {
|
|
@@ -339,7 +325,7 @@ class LoginHelper {
|
|
|
339
325
|
}
|
|
340
326
|
}
|
|
341
327
|
static async GetCredentialsForSecurityToken(securityToken) {
|
|
342
|
-
const [error, response] = await
|
|
328
|
+
const [error, response] = await to.to(fetch(`${LoginHelper.CMS_URL}/REST/Contensis/Security/IsAuthenticated`, {
|
|
343
329
|
method: 'POST',
|
|
344
330
|
headers: {
|
|
345
331
|
Accept: 'application/json',
|
|
@@ -353,13 +339,14 @@ class LoginHelper {
|
|
|
353
339
|
message: 'Failed to fetch credentials'
|
|
354
340
|
}];
|
|
355
341
|
if (response.ok) {
|
|
356
|
-
const [parseError, body] = await
|
|
342
|
+
const [parseError, body] = await to.to(response.json());
|
|
357
343
|
if (parseError) return [parseError];
|
|
358
344
|
const {
|
|
359
345
|
LogonResult,
|
|
360
346
|
ApplicationData = []
|
|
361
347
|
} = body;
|
|
362
348
|
if (LogonResult !== 0) {
|
|
349
|
+
console.info(`Security token is invalid - LogonResult: ${LogonResult}`);
|
|
363
350
|
return [{
|
|
364
351
|
message: 'Security token is invalid',
|
|
365
352
|
data: ApplicationData
|
|
@@ -402,14 +389,15 @@ LoginHelper.CMS_URL = SERVERS.cms /* global SERVERS */;
|
|
|
402
389
|
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context.WSFED_LOGIN === 'true';
|
|
403
390
|
LoginHelper.LOGIN_ROUTE = '/account/login';
|
|
404
391
|
LoginHelper.ACCESS_DENIED_ROUTE = '/account/access-denied';
|
|
392
|
+
LoginHelper.withCookies = cookieHelper => new LoginHelper(cookieHelper);
|
|
405
393
|
LoginHelper.GetUserDetails = async client => {
|
|
406
394
|
let userError,
|
|
407
395
|
groupsError,
|
|
408
396
|
user = {},
|
|
409
397
|
groupsResult;
|
|
410
|
-
[userError, user] = await
|
|
398
|
+
[userError, user] = await to.to(client.security.users.getCurrent());
|
|
411
399
|
if (user && user.id) {
|
|
412
|
-
[groupsError, groupsResult] = await
|
|
400
|
+
[groupsError, groupsResult] = await to.to(client.security.users.getUserGroups({
|
|
413
401
|
userId: user.id,
|
|
414
402
|
includeInherited: true,
|
|
415
403
|
pageOptions: {
|
|
@@ -431,7 +419,9 @@ const loginSagas = [effects.takeEvery(reducers.LOGIN_USER, loginUserSaga), effec
|
|
|
431
419
|
function* handleRequiresLoginSaga(action) {
|
|
432
420
|
var _entry$sys;
|
|
433
421
|
const {
|
|
422
|
+
cookies,
|
|
434
423
|
entry,
|
|
424
|
+
path,
|
|
435
425
|
requireLogin,
|
|
436
426
|
routes: {
|
|
437
427
|
ContentTypeMappings
|
|
@@ -460,14 +450,18 @@ function* handleRequiresLoginSaga(action) {
|
|
|
460
450
|
// If cookies or securityToken are found on any route change
|
|
461
451
|
// always validate and login the user
|
|
462
452
|
if (routeRequiresLogin) {
|
|
453
|
+
console.info(`Route requires login: ${path}`);
|
|
463
454
|
// If routeRequiresLogin do a blocking call that returns userLoggedIn
|
|
464
455
|
userLoggedIn = yield effects.call(validateUserSaga, {
|
|
456
|
+
cookies,
|
|
465
457
|
securityToken
|
|
466
458
|
});
|
|
459
|
+
console.info(`User logged in: ${userLoggedIn}`);
|
|
467
460
|
}
|
|
468
461
|
// otherwise do a non blocking put to handle validation in the background
|
|
469
462
|
else yield effects.put({
|
|
470
463
|
type: reducers.VALIDATE_USER,
|
|
464
|
+
cookies,
|
|
471
465
|
securityToken
|
|
472
466
|
});
|
|
473
467
|
}
|
|
@@ -482,13 +476,16 @@ function* handleRequiresLoginSaga(action) {
|
|
|
482
476
|
if (!groupMatch) LoginHelper.ClientRedirectToAccessDeniedPage(action.location.pathname);
|
|
483
477
|
}
|
|
484
478
|
}
|
|
479
|
+
return userLoggedIn;
|
|
485
480
|
}
|
|
486
481
|
function* validateUserSaga({
|
|
482
|
+
cookies,
|
|
487
483
|
securityToken
|
|
488
484
|
}) {
|
|
485
|
+
const login = LoginHelper.withCookies(cookies);
|
|
489
486
|
// Check for refreshToken in cookies
|
|
490
|
-
let clientCredentials =
|
|
491
|
-
if (securityToken || clientCredentials.refreshToken) {
|
|
487
|
+
let clientCredentials = login.GetCachedCredentials();
|
|
488
|
+
if (securityToken || clientCredentials.securityToken || clientCredentials.refreshToken) {
|
|
492
489
|
// We only attempt to validate the user if one of the stored
|
|
493
490
|
// tokens are found, in this case we set loading state manually
|
|
494
491
|
// so we don't need to set and unset loading if there are no stored
|
|
@@ -500,26 +497,36 @@ function* validateUserSaga({
|
|
|
500
497
|
});
|
|
501
498
|
// If we have just a security token we will call a CMS endpoint
|
|
502
499
|
// and provide us with a RefreshToken cookie we can use during login
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
500
|
+
if (securityToken || clientCredentials.securityToken && !clientCredentials.refreshToken) {
|
|
501
|
+
const [error, refreshToken] = yield LoginHelper.GetCredentialsForSecurityToken(securityToken || clientCredentials.securityToken);
|
|
502
|
+
if (refreshToken) {
|
|
503
|
+
// Set cookies and reload values
|
|
504
|
+
login.SetLoginCookies({
|
|
505
|
+
contensisClassicToken: securityToken,
|
|
506
|
+
refreshToken
|
|
507
|
+
});
|
|
508
|
+
clientCredentials = login.GetCachedCredentials();
|
|
509
|
+
}
|
|
510
|
+
if (error) {
|
|
511
|
+
login.ClearCachedCredentials();
|
|
512
|
+
yield effects.put({
|
|
513
|
+
type: reducers.SET_AUTHENTICATION_STATE,
|
|
514
|
+
authenticationState: {
|
|
515
|
+
isError: true,
|
|
516
|
+
errorMessage: (error === null || error === void 0 ? void 0 : error.message) || error && 'toString' in error && error.toString()
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
}
|
|
511
520
|
}
|
|
512
521
|
|
|
513
522
|
// Log the user in if a refreshToken is found
|
|
514
|
-
if (clientCredentials.refreshToken)
|
|
515
|
-
clientCredentials
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
+
if (clientCredentials.refreshToken) {
|
|
524
|
+
console.info(`Login user with refreshToken ${clientCredentials.refreshToken}`);
|
|
525
|
+
yield effects.call(loginUserSaga, {
|
|
526
|
+
clientCredentials,
|
|
527
|
+
cookies: login.cookies
|
|
528
|
+
});
|
|
529
|
+
}
|
|
523
530
|
}
|
|
524
531
|
|
|
525
532
|
// Tell any callers have we successfully logged in?
|
|
@@ -529,8 +536,10 @@ function* loginUserSaga(action = {}) {
|
|
|
529
536
|
const {
|
|
530
537
|
username,
|
|
531
538
|
password,
|
|
532
|
-
clientCredentials
|
|
539
|
+
clientCredentials,
|
|
540
|
+
cookies
|
|
533
541
|
} = action;
|
|
542
|
+
const login = LoginHelper.withCookies(cookies);
|
|
534
543
|
|
|
535
544
|
// If a WSFED_LOGIN site has dispatched the loginUser action
|
|
536
545
|
// just redirect them to the Identity Provider sign in
|
|
@@ -538,7 +547,7 @@ function* loginUserSaga(action = {}) {
|
|
|
538
547
|
const {
|
|
539
548
|
authenticationState,
|
|
540
549
|
user
|
|
541
|
-
} = yield
|
|
550
|
+
} = yield login.LoginUser({
|
|
542
551
|
username,
|
|
543
552
|
password,
|
|
544
553
|
clientCredentials
|
|
@@ -574,13 +583,14 @@ function* redirectAfterSuccessfulLoginSaga() {
|
|
|
574
583
|
}
|
|
575
584
|
}
|
|
576
585
|
function* logoutUserSaga({
|
|
577
|
-
redirectPath
|
|
586
|
+
redirectPath,
|
|
587
|
+
cookies
|
|
578
588
|
}) {
|
|
579
589
|
yield effects.put({
|
|
580
590
|
type: reducers.SET_AUTHENTICATION_STATE,
|
|
581
591
|
user: null
|
|
582
592
|
});
|
|
583
|
-
yield LoginHelper.LogoutUser(redirectPath);
|
|
593
|
+
yield LoginHelper.withCookies(cookies).LogoutUser(redirectPath);
|
|
584
594
|
}
|
|
585
595
|
function* refreshSecurityToken() {
|
|
586
596
|
const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
|
|
@@ -596,10 +606,162 @@ function* refreshSecurityToken() {
|
|
|
596
606
|
}
|
|
597
607
|
}
|
|
598
608
|
|
|
609
|
+
const loginUser = (username, password, cookies) => selectors.action(reducers.LOGIN_USER, {
|
|
610
|
+
username,
|
|
611
|
+
password,
|
|
612
|
+
cookies
|
|
613
|
+
});
|
|
614
|
+
const logoutUser = (redirectPath, cookies) => selectors.action(reducers.LOGOUT_USER, {
|
|
615
|
+
redirectPath,
|
|
616
|
+
cookies
|
|
617
|
+
});
|
|
618
|
+
const registerUser = (user, mappers) => selectors.action(reducers.REGISTER_USER, {
|
|
619
|
+
user,
|
|
620
|
+
mappers
|
|
621
|
+
});
|
|
622
|
+
const requestPasswordReset = userEmailObject => selectors.action(reducers.REQUEST_USER_PASSWORD_RESET, {
|
|
623
|
+
userEmailObject
|
|
624
|
+
});
|
|
625
|
+
const resetPassword = resetPasswordObject => selectors.action(reducers.RESET_USER_PASSWORD, {
|
|
626
|
+
resetPasswordObject
|
|
627
|
+
});
|
|
628
|
+
const changePassword = (userId, currentPassword, newPassword) => selectors.action(reducers.CHANGE_USER_PASSWORD, {
|
|
629
|
+
userId,
|
|
630
|
+
currentPassword,
|
|
631
|
+
newPassword
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
var actions = /*#__PURE__*/Object.freeze({
|
|
635
|
+
__proto__: null,
|
|
636
|
+
loginUser: loginUser,
|
|
637
|
+
logoutUser: logoutUser,
|
|
638
|
+
registerUser: registerUser,
|
|
639
|
+
requestPasswordReset: requestPasswordReset,
|
|
640
|
+
resetPassword: resetPassword,
|
|
641
|
+
changePassword: changePassword
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
const useLogin = () => {
|
|
645
|
+
const cookies = new ToJs.CookieHelper(...reactCookie.useCookies());
|
|
646
|
+
const dispatch = reactRedux.useDispatch();
|
|
647
|
+
const select = reactRedux.useSelector;
|
|
648
|
+
return {
|
|
649
|
+
loginUser: (username, password) => dispatch(loginUser(username, password, cookies)),
|
|
650
|
+
logoutUser: redirectPath => dispatch(logoutUser(redirectPath, cookies)),
|
|
651
|
+
errorMessage: select(ToJs.selectUserErrorMessage),
|
|
652
|
+
isAuthenticated: select(ToJs.selectUserIsAuthenticated),
|
|
653
|
+
isAuthenticationError: select(ToJs.selectUserIsAuthenticationError),
|
|
654
|
+
isError: select(ToJs.selectUserIsError),
|
|
655
|
+
isLoading: select(ToJs.selectUserIsLoading),
|
|
656
|
+
user: select(ToJs.selectUser),
|
|
657
|
+
// DEPRECATED: authenticationError is deprecated use isAuthenticationError instead
|
|
658
|
+
authenticationError: select(ToJs.selectUserIsAuthenticationError),
|
|
659
|
+
// DEPRECATED: authenticationErrorMessage is deprecated use errorMessage instead
|
|
660
|
+
authenticationErrorMessage: select(ToJs.selectUserErrorMessage),
|
|
661
|
+
// DEPRECATED: error is deprecated use isError instead
|
|
662
|
+
error: select(ToJs.selectUserIsError)
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
const LoginContainer = ({
|
|
667
|
+
children,
|
|
668
|
+
...props
|
|
669
|
+
}) => {
|
|
670
|
+
const userProps = useLogin();
|
|
671
|
+
return children(userProps);
|
|
672
|
+
};
|
|
673
|
+
LoginContainer.propTypes = {};
|
|
674
|
+
var Login_container = ToJs.toJS(LoginContainer);
|
|
675
|
+
|
|
676
|
+
const useRegistration = () => {
|
|
677
|
+
const dispatch = reactRedux.useDispatch();
|
|
678
|
+
const select = reactRedux.useSelector;
|
|
679
|
+
return {
|
|
680
|
+
registerUser: (user, mappers) => dispatch(registerUser(user, mappers)),
|
|
681
|
+
error: select(ToJs.selectUserRegistrationError),
|
|
682
|
+
isLoading: select(ToJs.selectUserRegistrationIsLoading),
|
|
683
|
+
isSuccess: select(ToJs.selectUserRegistrationIsSuccess),
|
|
684
|
+
user: select(ToJs.selectUserRegistration)
|
|
685
|
+
};
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
const RegistrationContainer = ({
|
|
689
|
+
children,
|
|
690
|
+
...props
|
|
691
|
+
}) => {
|
|
692
|
+
const userProps = useRegistration();
|
|
693
|
+
return children(userProps);
|
|
694
|
+
};
|
|
695
|
+
RegistrationContainer.propTypes = {};
|
|
696
|
+
var Registration_container = ToJs.toJS(RegistrationContainer);
|
|
697
|
+
|
|
698
|
+
const useForgotPassword = () => {
|
|
699
|
+
const dispatch = reactRedux.useDispatch();
|
|
700
|
+
const select = reactRedux.useSelector;
|
|
701
|
+
return {
|
|
702
|
+
isLoading: select(ToJs.selectPasswordResetRequestSending),
|
|
703
|
+
isSuccess: select(ToJs.selectPasswordResetRequestSent),
|
|
704
|
+
error: select(ToJs.selectPasswordResetRequestError),
|
|
705
|
+
requestPasswordReset: userEmailObject => dispatch(requestPasswordReset(userEmailObject)),
|
|
706
|
+
setNewPassword: {
|
|
707
|
+
queryString: select(selectors.selectCurrentSearch),
|
|
708
|
+
isLoading: select(ToJs.selectResetPasswordSending),
|
|
709
|
+
isSuccess: select(ToJs.selectResetPasswordSent),
|
|
710
|
+
error: select(ToJs.selectResetPasswordError),
|
|
711
|
+
submit: resetPasswordObject => dispatch(resetPassword(resetPasswordObject))
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
const ForgotPasswordContainer = ({
|
|
717
|
+
children,
|
|
718
|
+
...props
|
|
719
|
+
}) => {
|
|
720
|
+
const userProps = useForgotPassword();
|
|
721
|
+
return children(userProps);
|
|
722
|
+
};
|
|
723
|
+
ForgotPasswordContainer.propTypes = {};
|
|
724
|
+
var ForgotPassword_container = ToJs.toJS(ForgotPasswordContainer);
|
|
725
|
+
|
|
726
|
+
const useChangePassword = () => {
|
|
727
|
+
const dispatch = reactRedux.useDispatch();
|
|
728
|
+
const select = reactRedux.useSelector;
|
|
729
|
+
return {
|
|
730
|
+
isLoading: select(ToJs.selectChangePasswordSending),
|
|
731
|
+
isSuccess: select(ToJs.selectChangePasswordSent),
|
|
732
|
+
userId: select(ToJs.selectUserGuid),
|
|
733
|
+
isLoggedIn: select(ToJs.selectUserIsAuthenticated),
|
|
734
|
+
error: select(ToJs.selectChangePasswordError),
|
|
735
|
+
changePassword: (userId, currentPassword, newPassword) => dispatch(changePassword(userId, currentPassword, newPassword))
|
|
736
|
+
};
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
const ChangePasswordContainer = ({
|
|
740
|
+
children,
|
|
741
|
+
...props
|
|
742
|
+
}) => {
|
|
743
|
+
const userProps = useChangePassword();
|
|
744
|
+
return children(userProps);
|
|
745
|
+
};
|
|
746
|
+
ChangePasswordContainer.propTypes = {};
|
|
747
|
+
var ChangePassword_container = ToJs.toJS(ChangePasswordContainer);
|
|
748
|
+
|
|
749
|
+
exports.ChangePassword_container = ChangePassword_container;
|
|
750
|
+
exports.ForgotPassword_container = ForgotPassword_container;
|
|
599
751
|
exports.LoginHelper = LoginHelper;
|
|
752
|
+
exports.Login_container = Login_container;
|
|
753
|
+
exports.Registration_container = Registration_container;
|
|
754
|
+
exports.actions = actions;
|
|
600
755
|
exports.findContentTypeMapping = findContentTypeMapping;
|
|
601
756
|
exports.getManagementApiClient = getManagementApiClient;
|
|
602
757
|
exports.handleRequiresLoginSaga = handleRequiresLoginSaga;
|
|
603
758
|
exports.loginSagas = loginSagas;
|
|
759
|
+
exports.loginUser = loginUser;
|
|
760
|
+
exports.logoutUser = logoutUser;
|
|
604
761
|
exports.refreshSecurityToken = refreshSecurityToken;
|
|
605
|
-
|
|
762
|
+
exports.registerUser = registerUser;
|
|
763
|
+
exports.useChangePassword = useChangePassword;
|
|
764
|
+
exports.useForgotPassword = useForgotPassword;
|
|
765
|
+
exports.useLogin = useLogin;
|
|
766
|
+
exports.useRegistration = useRegistration;
|
|
767
|
+
//# sourceMappingURL=ChangePassword.container-f3f94d8f.js.map
|