@zengenti/contensis-react-base 3.0.2-beta.4 → 3.0.2-beta.40
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 +2 -2
- package/cjs/{App-a2783f8b.js → App-7ff737fa.js} +161 -444
- package/cjs/App-7ff737fa.js.map +1 -0
- package/cjs/{login-e711a19e.js → ChangePassword.container-a617190b.js} +304 -191
- package/cjs/ChangePassword.container-a617190b.js.map +1 -0
- package/cjs/ContensisDeliveryApi-9e32960d.js +265 -0
- package/cjs/ContensisDeliveryApi-9e32960d.js.map +1 -0
- package/cjs/CookieConstants-000427db.js +10 -0
- package/cjs/CookieConstants-000427db.js.map +1 -0
- package/cjs/{RouteLoader-3aa6456e.js → RouteLoader-049e81e5.js} +27 -38
- package/cjs/RouteLoader-049e81e5.js.map +1 -0
- package/cjs/{ToJs-a9a8522b.js → ToJs-149fc5e1.js} +50 -4
- package/cjs/ToJs-149fc5e1.js.map +1 -0
- package/cjs/_commonjsHelpers-b3309d7b.js +11 -0
- package/cjs/_commonjsHelpers-b3309d7b.js.map +1 -0
- package/cjs/client.js +25 -30
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +158 -536
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/forms.js +3555 -326
- 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/{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 -18
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +7 -7
- 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-46b689d0.js} +86 -9
- package/cjs/selectors-46b689d0.js.map +1 -0
- package/cjs/urls-6fcaf4c6.js.map +1 -1
- package/cjs/user.js +34 -169
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +47 -53
- package/cjs/util.js.map +1 -1
- package/cjs/{version-bf9ef45e.js → version-79a027cb.js} +55 -179
- package/cjs/version-79a027cb.js.map +1 -0
- package/cjs/version-afd4f77e.js +98 -0
- package/cjs/version-afd4f77e.js.map +1 -0
- package/esm/{App-17d1ac3c.js → App-ff944c78.js} +145 -427
- package/esm/App-ff944c78.js.map +1 -0
- package/esm/{login-551d243a.js → ChangePassword.container-ae0f9ce4.js} +286 -184
- package/esm/ChangePassword.container-ae0f9ce4.js.map +1 -0
- package/esm/ContensisDeliveryApi-c66b0cc3.js +259 -0
- package/esm/ContensisDeliveryApi-c66b0cc3.js.map +1 -0
- package/esm/CookieConstants-3d3b6531.js +6 -0
- package/esm/CookieConstants-3d3b6531.js.map +1 -0
- package/esm/{RouteLoader-5171c63f.js → RouteLoader-02eef6d9.js} +26 -37
- package/esm/RouteLoader-02eef6d9.js.map +1 -0
- package/esm/{ToJs-4e02a04d.js → ToJs-ae860aad.js} +50 -5
- package/esm/ToJs-ae860aad.js.map +1 -0
- package/esm/_commonjsHelpers-1789f0cf.js +8 -0
- package/esm/_commonjsHelpers-1789f0cf.js.map +1 -0
- package/esm/client.js +20 -25
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +151 -530
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/forms.js +3557 -328
- 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/{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 -9
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +4 -4
- 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-01074974.js} +71 -9
- package/esm/selectors-01074974.js.map +1 -0
- package/esm/urls-eac9a747.js.map +1 -1
- package/esm/user.js +22 -161
- package/esm/user.js.map +1 -1
- package/esm/util.js +42 -53
- package/esm/util.js.map +1 -1
- package/esm/version-0fbd1b82.js +87 -0
- package/esm/version-0fbd1b82.js.map +1 -0
- package/esm/{version-72ca17f3.js → version-346a9787.js} +43 -162
- package/esm/version-346a9787.js.map +1 -0
- 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 -38
- package/models/util/LruCache.d.ts +12 -0
- package/models/util/ToJs.d.ts +1 -1
- package/models/util/index.d.ts +1 -0
- package/models/util/json-mapper.d.ts +1 -1
- package/package.json +9 -10
- package/cjs/App-a2783f8b.js.map +0 -1
- package/cjs/RouteLoader-3aa6456e.js.map +0 -1
- package/cjs/ToJs-a9a8522b.js.map +0 -1
- package/cjs/actions-8dc9e8de.js +0 -87
- package/cjs/actions-8dc9e8de.js.map +0 -1
- package/cjs/login-e711a19e.js.map +0 -1
- package/cjs/sagas-8a20e424.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/RouteLoader-5171c63f.js.map +0 -1
- package/esm/ToJs-4e02a04d.js.map +0 -1
- package/esm/actions-180948dd.js +0 -72
- package/esm/actions-180948dd.js.map +0 -1
- package/esm/login-551d243a.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-72ca17f3.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var effects = require('@redux-saga/core/effects');
|
|
4
|
-
var reducers = require('./reducers-
|
|
5
|
-
var ToJs = require('./ToJs-
|
|
6
|
-
var
|
|
7
|
-
var selectors = require('./selectors-656da4b7.js');
|
|
4
|
+
var reducers = require('./reducers-9afb5f89.js');
|
|
5
|
+
var ToJs = require('./ToJs-149fc5e1.js');
|
|
6
|
+
var selectors = require('./selectors-46b689d0.js');
|
|
8
7
|
var mapJson = require('jsonpath-mapper');
|
|
9
|
-
var
|
|
10
|
-
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');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
14
|
|
|
@@ -30,7 +31,6 @@ function _interopNamespace(e) {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
var mapJson__default = /*#__PURE__*/_interopDefaultLegacy(mapJson);
|
|
33
|
-
var JSCookie__default = /*#__PURE__*/_interopDefaultLegacy(JSCookie);
|
|
34
34
|
|
|
35
35
|
const findContentTypeMapping = (ContentTypeMappings, contentTypeId) => ContentTypeMappings.find(ct => ct.contentTypeID === contentTypeId);
|
|
36
36
|
|
|
@@ -48,6 +48,7 @@ const clientCredentials = {
|
|
|
48
48
|
var mapClientCredentials = (obj => mapJson__default["default"](obj, clientCredentials));
|
|
49
49
|
|
|
50
50
|
// import { Client } from 'contensis-management-api';
|
|
51
|
+
|
|
51
52
|
const getManagementApiClient = async ({
|
|
52
53
|
bearerToken,
|
|
53
54
|
bearerTokenExpiryDate,
|
|
@@ -57,14 +58,10 @@ const getManagementApiClient = async ({
|
|
|
57
58
|
username,
|
|
58
59
|
password
|
|
59
60
|
}) => {
|
|
60
|
-
const rootUrl = SERVERS.api || SERVERS.cms;
|
|
61
|
-
/* global
|
|
62
|
-
|
|
63
|
-
const projectId = PROJECTS[0].id;
|
|
64
|
-
/* global PROJECTS */
|
|
61
|
+
const rootUrl = SERVERS.api || SERVERS.cms; /* global SERVERS */
|
|
62
|
+
const projectId = PROJECTS[0].id; /* global PROJECTS */
|
|
65
63
|
|
|
66
64
|
let config = {};
|
|
67
|
-
|
|
68
65
|
if (refreshToken) {
|
|
69
66
|
config = {
|
|
70
67
|
clientType: 'contensis_classic_refresh_token',
|
|
@@ -81,11 +78,17 @@ const getManagementApiClient = async ({
|
|
|
81
78
|
}
|
|
82
79
|
};
|
|
83
80
|
}
|
|
84
|
-
|
|
85
|
-
const {
|
|
81
|
+
let {
|
|
86
82
|
Client
|
|
87
83
|
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('contensis-management-api')); });
|
|
88
|
-
|
|
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
|
+
}
|
|
90
|
+
const client = Client.create({
|
|
91
|
+
...config,
|
|
89
92
|
projectId,
|
|
90
93
|
rootUrl
|
|
91
94
|
});
|
|
@@ -97,43 +100,9 @@ const getManagementApiClient = async ({
|
|
|
97
100
|
return client;
|
|
98
101
|
};
|
|
99
102
|
|
|
100
|
-
const COOKIE_VALID_DAYS = 1; // 0 = Session cookie
|
|
101
|
-
// Override the default js-cookie conversion / encoding
|
|
102
|
-
// methods so the written values work with Contensis sites
|
|
103
|
-
|
|
104
|
-
const Cookies = JSCookie__default["default"].withConverter({
|
|
105
|
-
read: value => decodeURIComponent(value),
|
|
106
|
-
write: value => encodeURIComponent(value)
|
|
107
|
-
});
|
|
108
|
-
class CookieHelper {
|
|
109
|
-
static GetCookie(name) {
|
|
110
|
-
const cookie = Cookies.get(name);
|
|
111
|
-
|
|
112
|
-
if (typeof cookie === 'undefined') {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return cookie;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
static SetCookie(name, value, maxAgeDays = COOKIE_VALID_DAYS) {
|
|
120
|
-
if (maxAgeDays === 0) Cookies.set(name, value);else Cookies.set(name, value, {
|
|
121
|
-
expires: maxAgeDays
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
static DeleteCookie(name) {
|
|
126
|
-
Cookies.remove(name);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
103
|
const context$1 = typeof window != 'undefined' ? window : global;
|
|
132
|
-
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
133
|
-
/* global
|
|
134
|
-
: context$1.WSFED_LOGIN === 'true';
|
|
135
|
-
const servers = SERVERS;
|
|
136
|
-
/* global SERVERS */
|
|
104
|
+
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context$1.WSFED_LOGIN === 'true';
|
|
105
|
+
const servers = SERVERS; /* global SERVERS */
|
|
137
106
|
|
|
138
107
|
const userManagerConfig = typeof window !== 'undefined' ? {
|
|
139
108
|
authority: `${servers.cms}/authenticate/`,
|
|
@@ -149,9 +118,7 @@ const createUserManager = async config => {
|
|
|
149
118
|
try {
|
|
150
119
|
const {
|
|
151
120
|
UserManager
|
|
152
|
-
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
|
|
153
|
-
/* webpackChunkName: "oidcclient" */
|
|
154
|
-
'oidc-client')); });
|
|
121
|
+
} = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require( /* webpackChunkName: "oidcclient" */'oidc-client')); });
|
|
155
122
|
return new UserManager(config);
|
|
156
123
|
} catch (e) {
|
|
157
124
|
console.error('Exception in createUserManager: ', e);
|
|
@@ -160,50 +127,46 @@ const createUserManager = async config => {
|
|
|
160
127
|
};
|
|
161
128
|
|
|
162
129
|
/* eslint-disable require-atomic-updates */
|
|
163
|
-
const LOGIN_COOKIE = 'ContensisCMSUserName';
|
|
164
|
-
const REFRESH_TOKEN_COOKIE = 'RefreshToken';
|
|
165
130
|
const context = typeof window != 'undefined' ? window : global;
|
|
166
131
|
class LoginHelper {
|
|
167
|
-
|
|
132
|
+
constructor(cookies) {
|
|
133
|
+
this.cookies = void 0;
|
|
134
|
+
this.cookies = cookies;
|
|
135
|
+
}
|
|
136
|
+
SetLoginCookies({
|
|
168
137
|
contensisClassicToken,
|
|
169
138
|
refreshToken
|
|
170
139
|
}) {
|
|
171
|
-
console.info('SetLoginCookies:', LOGIN_COOKIE, contensisClassicToken, REFRESH_TOKEN_COOKIE, refreshToken);
|
|
172
|
-
if (contensisClassicToken)
|
|
173
|
-
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);
|
|
174
143
|
}
|
|
175
|
-
|
|
176
|
-
static GetCachedCredentials() {
|
|
144
|
+
GetCachedCredentials() {
|
|
177
145
|
return {
|
|
178
146
|
bearerToken: null,
|
|
179
147
|
bearerTokenExpiryDate: null,
|
|
180
|
-
refreshToken:
|
|
148
|
+
refreshToken: this.cookies.GetCookie(CookieConstants.REFRESH_TOKEN_COOKIE),
|
|
181
149
|
refreshTokenExpiryDate: null,
|
|
182
|
-
contensisClassicToken:
|
|
150
|
+
contensisClassicToken: this.cookies.GetCookie(CookieConstants.LOGIN_COOKIE)
|
|
183
151
|
};
|
|
184
152
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
CookieHelper.DeleteCookie(REFRESH_TOKEN_COOKIE);
|
|
189
|
-
|
|
153
|
+
ClearCachedCredentials() {
|
|
154
|
+
this.cookies.DeleteCookie(CookieConstants.LOGIN_COOKIE);
|
|
155
|
+
this.cookies.DeleteCookie(CookieConstants.REFRESH_TOKEN_COOKIE);
|
|
190
156
|
if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
|
|
191
157
|
// remove any oidc keys left over in localStorage
|
|
192
158
|
const {
|
|
193
159
|
localStorage
|
|
194
160
|
} = window;
|
|
195
161
|
const keys = [];
|
|
196
|
-
|
|
197
162
|
for (let i = 0; i < localStorage.length; i++) {
|
|
198
163
|
const key = localStorage.key(i);
|
|
199
164
|
if (typeof key === 'string' && key.startsWith('oidc.')) keys.push(localStorage.key(i));
|
|
200
165
|
}
|
|
201
|
-
|
|
202
166
|
keys.forEach(key => localStorage.removeItem(key));
|
|
203
167
|
}
|
|
204
168
|
}
|
|
205
|
-
|
|
206
|
-
static async LoginUser({
|
|
169
|
+
async LoginUser({
|
|
207
170
|
username,
|
|
208
171
|
password,
|
|
209
172
|
clientCredentials
|
|
@@ -217,16 +180,17 @@ class LoginHelper {
|
|
|
217
180
|
};
|
|
218
181
|
let transientClient;
|
|
219
182
|
let user;
|
|
220
|
-
|
|
221
183
|
if (username && password) {
|
|
222
184
|
// Get a management client with username and password
|
|
223
185
|
transientClient = await getManagementApiClient({
|
|
224
186
|
username,
|
|
225
187
|
password
|
|
226
|
-
});
|
|
188
|
+
});
|
|
227
189
|
|
|
228
|
-
|
|
190
|
+
// Ensure the client has requested a bearer token
|
|
191
|
+
const [loginError, clientBearerToken] = await to.to(transientClient.ensureBearerToken());
|
|
229
192
|
|
|
193
|
+
// Problem getting token with username and password
|
|
230
194
|
if (loginError) {
|
|
231
195
|
authenticationState = {
|
|
232
196
|
clientCredentials: null,
|
|
@@ -235,14 +199,14 @@ class LoginHelper {
|
|
|
235
199
|
isAuthenticationError: loginError.name.includes('ContensisAuthenticationError'),
|
|
236
200
|
isError: true
|
|
237
201
|
};
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
202
|
+
this.ClearCachedCredentials();
|
|
203
|
+
}
|
|
241
204
|
|
|
205
|
+
// Got a token using username and password
|
|
242
206
|
if (clientBearerToken) {
|
|
243
207
|
// Set credentials so we can continue to GetUserDetails
|
|
244
208
|
credentials = mapClientCredentials(transientClient);
|
|
245
|
-
|
|
209
|
+
this.SetLoginCookies(credentials);
|
|
246
210
|
authenticationState = {
|
|
247
211
|
clientCredentials: credentials,
|
|
248
212
|
isAuthenticated: true,
|
|
@@ -250,15 +214,14 @@ class LoginHelper {
|
|
|
250
214
|
isError: false
|
|
251
215
|
};
|
|
252
216
|
}
|
|
253
|
-
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// If we have credentials supplied by a successful username and password login
|
|
254
220
|
// or clientCredentials supplied in the options argument we can continue to
|
|
255
221
|
// fetch the user's details
|
|
256
|
-
|
|
257
|
-
|
|
258
222
|
if (credentials) {
|
|
259
223
|
const client = transientClient || (await getManagementApiClient(credentials));
|
|
260
224
|
const [error, userDetails] = await LoginHelper.GetUserDetails(client);
|
|
261
|
-
|
|
262
225
|
if (error) {
|
|
263
226
|
authenticationState = {
|
|
264
227
|
clientCredentials: null,
|
|
@@ -267,11 +230,11 @@ class LoginHelper {
|
|
|
267
230
|
isAuthenticationError: false,
|
|
268
231
|
isError: true
|
|
269
232
|
};
|
|
270
|
-
|
|
233
|
+
this.ClearCachedCredentials();
|
|
271
234
|
} else {
|
|
272
235
|
// Ensure we get latest refreshToken and contensisClassicToken from the latest client
|
|
273
236
|
const latestCredentials = mapClientCredentials(client);
|
|
274
|
-
|
|
237
|
+
this.SetLoginCookies(latestCredentials);
|
|
275
238
|
user = userDetails;
|
|
276
239
|
authenticationState = {
|
|
277
240
|
clientCredentials: latestCredentials,
|
|
@@ -281,27 +244,22 @@ class LoginHelper {
|
|
|
281
244
|
};
|
|
282
245
|
}
|
|
283
246
|
}
|
|
284
|
-
|
|
285
247
|
return {
|
|
286
248
|
authenticationState,
|
|
287
249
|
user
|
|
288
250
|
};
|
|
289
251
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
LoginHelper.ClearCachedCredentials();
|
|
293
|
-
|
|
252
|
+
LogoutUser(redirectPath) {
|
|
253
|
+
this.ClearCachedCredentials();
|
|
294
254
|
if (LoginHelper.WSFED_LOGIN) {
|
|
295
255
|
LoginHelper.WsFedLogout(redirectPath);
|
|
296
256
|
} else {
|
|
297
257
|
if (redirectPath) LoginHelper.ClientRedirectToPath(redirectPath);else LoginHelper.ClientRedirectToSignInPage();
|
|
298
258
|
}
|
|
299
259
|
}
|
|
300
|
-
|
|
301
260
|
static ClientRedirectToHome(location) {
|
|
302
261
|
if (typeof window != 'undefined') {
|
|
303
262
|
let url = '/';
|
|
304
|
-
|
|
305
263
|
if (location) {
|
|
306
264
|
const {
|
|
307
265
|
search,
|
|
@@ -310,12 +268,11 @@ class LoginHelper {
|
|
|
310
268
|
url = search ? `${url}${search}` : url;
|
|
311
269
|
url = hash ? `${url}${hash}` : url;
|
|
312
270
|
}
|
|
313
|
-
|
|
314
271
|
window.location.href = url;
|
|
315
272
|
}
|
|
316
273
|
}
|
|
317
|
-
|
|
318
274
|
static async ClientRedirectToSignInPage(redirectPath) {
|
|
275
|
+
if (typeof location === 'undefined') return;
|
|
319
276
|
if (LoginHelper.WSFED_LOGIN) {
|
|
320
277
|
await LoginHelper.WsFedLogout();
|
|
321
278
|
await LoginHelper.WsFedLogin();
|
|
@@ -326,20 +283,19 @@ class LoginHelper {
|
|
|
326
283
|
if (typeof location !== 'undefined' && redirectPath !== LoginHelper.LOGIN_ROUTE) location.replace(url);
|
|
327
284
|
}
|
|
328
285
|
}
|
|
329
|
-
|
|
330
|
-
static ClientRedirectToAccessDeniedPage(originalPath) {
|
|
286
|
+
static GetAccessDeniedRoute(originalPath) {
|
|
331
287
|
let url = LoginHelper.ACCESS_DENIED_ROUTE;
|
|
332
|
-
if (originalPath ===
|
|
333
|
-
|
|
334
|
-
|
|
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);
|
|
335
293
|
}
|
|
336
|
-
|
|
337
294
|
static ClientRedirectToPath(redirectPath) {
|
|
338
295
|
if (typeof redirectPath === 'string') {
|
|
339
296
|
if (typeof location !== 'undefined') window.location.href = redirectPath;
|
|
340
297
|
} else LoginHelper.ClientRedirectToHome();
|
|
341
298
|
}
|
|
342
|
-
|
|
343
299
|
static async WsFedLogin(redirectUri) {
|
|
344
300
|
const userManager = await createUserManager(userManagerConfig);
|
|
345
301
|
userManager.signinRedirect({
|
|
@@ -348,22 +304,18 @@ class LoginHelper {
|
|
|
348
304
|
redirect_uri: redirectUri || window.location.toString()
|
|
349
305
|
});
|
|
350
306
|
}
|
|
351
|
-
|
|
352
307
|
static RemoveSecurityTokenQuery() {
|
|
353
308
|
const params = new URLSearchParams(window.location.search);
|
|
354
|
-
|
|
355
309
|
if (params.has('securitytoken') || params.has('securityToken')) {
|
|
356
310
|
params.delete('securitytoken');
|
|
357
311
|
params.delete('securityToken');
|
|
358
312
|
window.location = `${window.location.pathname}${params.toString() ? `?${params}` : ''}`;
|
|
359
313
|
}
|
|
360
314
|
}
|
|
361
|
-
|
|
362
315
|
static async WsFedLogout(redirectPath) {
|
|
363
316
|
await fetch(`${LoginHelper.CMS_URL}/authenticate/logout?jsonResponseRequired=true`, {
|
|
364
317
|
credentials: 'include'
|
|
365
318
|
});
|
|
366
|
-
|
|
367
319
|
if (redirectPath) {
|
|
368
320
|
window.location = redirectPath;
|
|
369
321
|
} else {
|
|
@@ -372,9 +324,8 @@ class LoginHelper {
|
|
|
372
324
|
LoginHelper.RemoveSecurityTokenQuery();
|
|
373
325
|
}
|
|
374
326
|
}
|
|
375
|
-
|
|
376
327
|
static async GetCredentialsForSecurityToken(securityToken) {
|
|
377
|
-
const [error, response] = await
|
|
328
|
+
const [error, response] = await to.to(fetch(`${LoginHelper.CMS_URL}/REST/Contensis/Security/IsAuthenticated`, {
|
|
378
329
|
method: 'POST',
|
|
379
330
|
headers: {
|
|
380
331
|
Accept: 'application/json',
|
|
@@ -387,34 +338,30 @@ class LoginHelper {
|
|
|
387
338
|
if (error) return [{
|
|
388
339
|
message: 'Failed to fetch credentials'
|
|
389
340
|
}];
|
|
390
|
-
|
|
391
341
|
if (response.ok) {
|
|
392
|
-
const [parseError, body] = await
|
|
342
|
+
const [parseError, body] = await to.to(response.json());
|
|
393
343
|
if (parseError) return [parseError];
|
|
394
344
|
const {
|
|
395
345
|
LogonResult,
|
|
396
346
|
ApplicationData = []
|
|
397
347
|
} = body;
|
|
398
|
-
|
|
399
348
|
if (LogonResult !== 0) {
|
|
349
|
+
console.info(`Security token is invalid - LogonResult: ${LogonResult}`);
|
|
400
350
|
return [{
|
|
401
351
|
message: 'Security token is invalid',
|
|
402
352
|
data: ApplicationData
|
|
403
353
|
}];
|
|
404
354
|
}
|
|
405
|
-
|
|
406
355
|
if (ApplicationData.length > 0) {
|
|
407
356
|
let refreshToken;
|
|
408
357
|
ApplicationData.forEach(item => {
|
|
409
358
|
if (item.Key === 'ContensisSecurityRefreshToken') refreshToken = item.Value;
|
|
410
359
|
});
|
|
411
|
-
|
|
412
360
|
if (!refreshToken) {
|
|
413
361
|
return [{
|
|
414
362
|
message: 'Fetch credentials: Unable to find ContensisSecurityRefreshToken'
|
|
415
363
|
}];
|
|
416
364
|
}
|
|
417
|
-
|
|
418
365
|
return [undefined, refreshToken];
|
|
419
366
|
} else {
|
|
420
367
|
return [{
|
|
@@ -426,92 +373,98 @@ class LoginHelper {
|
|
|
426
373
|
message: `Fetch credentials error: ${response.status} ${response.statusText}`
|
|
427
374
|
}];
|
|
428
375
|
}
|
|
429
|
-
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// static isZengentiStaff(email) {
|
|
430
379
|
// const emailRefs = ['@zengenti', '@contensis'];
|
|
380
|
+
|
|
431
381
|
// return emailRefs.some(emailRef => {
|
|
432
382
|
// if (email.includes(emailRef)) {
|
|
433
383
|
// return true;
|
|
434
384
|
// }
|
|
435
385
|
// });
|
|
436
386
|
// }
|
|
437
|
-
|
|
438
|
-
|
|
439
387
|
}
|
|
440
|
-
LoginHelper.CMS_URL = SERVERS.cms
|
|
441
|
-
/* global
|
|
442
|
-
;
|
|
443
|
-
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
444
|
-
/* global WSFED_LOGIN */
|
|
445
|
-
: context.WSFED_LOGIN === 'true';
|
|
388
|
+
LoginHelper.CMS_URL = SERVERS.cms /* global SERVERS */;
|
|
389
|
+
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context.WSFED_LOGIN === 'true';
|
|
446
390
|
LoginHelper.LOGIN_ROUTE = '/account/login';
|
|
447
391
|
LoginHelper.ACCESS_DENIED_ROUTE = '/account/access-denied';
|
|
448
|
-
|
|
392
|
+
LoginHelper.withCookies = cookieHelper => new LoginHelper(cookieHelper);
|
|
449
393
|
LoginHelper.GetUserDetails = async client => {
|
|
450
394
|
let userError,
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
[userError, user] = await
|
|
455
|
-
|
|
395
|
+
groupsError,
|
|
396
|
+
user = {},
|
|
397
|
+
groupsResult;
|
|
398
|
+
[userError, user] = await to.to(client.security.users.getCurrent());
|
|
456
399
|
if (user && user.id) {
|
|
457
|
-
[groupsError, groupsResult] = await
|
|
400
|
+
[groupsError, groupsResult] = await to.to(client.security.users.getUserGroups({
|
|
458
401
|
userId: user.id,
|
|
459
|
-
includeInherited: true
|
|
460
|
-
|
|
402
|
+
includeInherited: true,
|
|
403
|
+
pageOptions: {
|
|
404
|
+
pageSize: 100
|
|
405
|
+
}
|
|
406
|
+
}));
|
|
407
|
+
// Set groups attribute in user object to be the items
|
|
461
408
|
// array from the getUserGroups result
|
|
409
|
+
if (groupsResult && groupsResult.items) user.groups = groupsResult.items;
|
|
462
410
|
|
|
463
|
-
|
|
411
|
+
//If groups call fails then log the error but allow the user to login still
|
|
464
412
|
// eslint-disable-next-line no-console
|
|
465
|
-
|
|
466
413
|
if (groupsError) console.log(groupsError);
|
|
467
414
|
}
|
|
468
|
-
|
|
469
415
|
return [userError, user];
|
|
470
416
|
};
|
|
471
417
|
|
|
472
418
|
const loginSagas = [effects.takeEvery(reducers.LOGIN_USER, loginUserSaga), effects.takeEvery(reducers.LOGOUT_USER, logoutUserSaga), effects.takeEvery(reducers.VALIDATE_USER, validateUserSaga), effects.takeEvery(reducers.SET_AUTHENTICATION_STATE, redirectAfterSuccessfulLoginSaga)];
|
|
473
419
|
function* handleRequiresLoginSaga(action) {
|
|
474
420
|
var _entry$sys;
|
|
475
|
-
|
|
476
421
|
const {
|
|
422
|
+
cookies,
|
|
477
423
|
entry,
|
|
424
|
+
path,
|
|
478
425
|
requireLogin,
|
|
479
426
|
routes: {
|
|
480
427
|
ContentTypeMappings
|
|
481
428
|
},
|
|
482
429
|
staticRoute
|
|
483
430
|
} = action;
|
|
484
|
-
let userLoggedIn = yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
431
|
+
let userLoggedIn = yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
485
432
|
|
|
433
|
+
// Check for a securityToken in querystring
|
|
486
434
|
const currentQs = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
487
|
-
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
435
|
+
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
488
436
|
|
|
437
|
+
// Check if any of the defined routes have "requireLogin" attribute
|
|
489
438
|
const {
|
|
490
439
|
requireLogin: authRoute
|
|
491
440
|
} = staticRoute && staticRoute.route || {};
|
|
492
441
|
const {
|
|
493
442
|
requireLogin: authContentType
|
|
494
|
-
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 ? void 0 : (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
495
|
-
// array of groups we can merge all the arrays and match on any group supplied
|
|
443
|
+
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 ? void 0 : (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
496
444
|
|
|
445
|
+
// If requireLogin, authRoute or authContentType has been specified as an
|
|
446
|
+
// array of groups we can merge all the arrays and match on any group supplied
|
|
497
447
|
const routeRequiresGroups = [...(Array.isArray(authContentType) && authContentType || []), ...(Array.isArray(authRoute) && authRoute || []), ...(Array.isArray(requireLogin) && requireLogin || [])];
|
|
498
448
|
const routeRequiresLogin = !!authContentType || !!authRoute || !!requireLogin;
|
|
499
|
-
|
|
500
449
|
if (!userLoggedIn) {
|
|
501
450
|
// If cookies or securityToken are found on any route change
|
|
502
451
|
// always validate and login the user
|
|
503
452
|
if (routeRequiresLogin) {
|
|
453
|
+
console.info(`Route requires login: ${path}`);
|
|
504
454
|
// If routeRequiresLogin do a blocking call that returns userLoggedIn
|
|
505
455
|
userLoggedIn = yield effects.call(validateUserSaga, {
|
|
456
|
+
cookies,
|
|
506
457
|
securityToken
|
|
507
458
|
});
|
|
508
|
-
|
|
459
|
+
console.info(`User logged in: ${userLoggedIn}`);
|
|
460
|
+
}
|
|
461
|
+
// otherwise do a non blocking put to handle validation in the background
|
|
509
462
|
else yield effects.put({
|
|
510
463
|
type: reducers.VALIDATE_USER,
|
|
464
|
+
cookies,
|
|
511
465
|
securityToken
|
|
512
466
|
});
|
|
513
467
|
}
|
|
514
|
-
|
|
515
468
|
if (routeRequiresLogin) {
|
|
516
469
|
// If a security token is in the querystring and we are not already
|
|
517
470
|
// logged in something is wrong and we won't bother going on another redirect loop
|
|
@@ -523,15 +476,16 @@ function* handleRequiresLoginSaga(action) {
|
|
|
523
476
|
if (!groupMatch) LoginHelper.ClientRedirectToAccessDeniedPage(action.location.pathname);
|
|
524
477
|
}
|
|
525
478
|
}
|
|
479
|
+
return userLoggedIn;
|
|
526
480
|
}
|
|
527
|
-
|
|
528
481
|
function* validateUserSaga({
|
|
482
|
+
cookies,
|
|
529
483
|
securityToken
|
|
530
484
|
}) {
|
|
485
|
+
const login = LoginHelper.withCookies(cookies);
|
|
531
486
|
// Check for refreshToken in cookies
|
|
532
|
-
let clientCredentials =
|
|
533
|
-
|
|
534
|
-
if (securityToken || clientCredentials.refreshToken) {
|
|
487
|
+
let clientCredentials = login.GetCachedCredentials();
|
|
488
|
+
if (securityToken || clientCredentials.securityToken || clientCredentials.refreshToken) {
|
|
535
489
|
// We only attempt to validate the user if one of the stored
|
|
536
490
|
// tokens are found, in this case we set loading state manually
|
|
537
491
|
// so we don't need to set and unset loading if there are no stored
|
|
@@ -540,49 +494,60 @@ function* validateUserSaga({
|
|
|
540
494
|
authenticationState: {
|
|
541
495
|
isLoading: true
|
|
542
496
|
}
|
|
543
|
-
});
|
|
497
|
+
});
|
|
498
|
+
// If we have just a security token we will call a CMS endpoint
|
|
544
499
|
// and provide us with a RefreshToken cookie we can use during login
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
clientCredentials = LoginHelper.GetCachedCredentials();
|
|
555
|
-
} // Log the user in if a refreshToken is found
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if (clientCredentials.refreshToken) yield effects.call(loginUserSaga, {
|
|
559
|
-
clientCredentials
|
|
560
|
-
});else if (error) yield effects.put({
|
|
561
|
-
type: reducers.SET_AUTHENTICATION_STATE,
|
|
562
|
-
authenticationState: {
|
|
563
|
-
isError: true,
|
|
564
|
-
errorMessage: (error === null || error === void 0 ? void 0 : error.message) || error && 'toString' in error && error.toString()
|
|
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();
|
|
565
509
|
}
|
|
566
|
-
|
|
567
|
-
|
|
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
|
+
}
|
|
520
|
+
}
|
|
568
521
|
|
|
522
|
+
// Log the user in if a refreshToken is found
|
|
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
|
+
}
|
|
530
|
+
}
|
|
569
531
|
|
|
532
|
+
// Tell any callers have we successfully logged in?
|
|
570
533
|
return yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
571
534
|
}
|
|
572
|
-
|
|
573
535
|
function* loginUserSaga(action = {}) {
|
|
574
536
|
const {
|
|
575
537
|
username,
|
|
576
538
|
password,
|
|
577
|
-
clientCredentials
|
|
578
|
-
|
|
579
|
-
|
|
539
|
+
clientCredentials,
|
|
540
|
+
cookies
|
|
541
|
+
} = action;
|
|
542
|
+
const login = LoginHelper.withCookies(cookies);
|
|
580
543
|
|
|
544
|
+
// If a WSFED_LOGIN site has dispatched the loginUser action
|
|
545
|
+
// just redirect them to the Identity Provider sign in
|
|
581
546
|
if (action.type === reducers.LOGIN_USER && LoginHelper.WSFED_LOGIN) LoginHelper.ClientRedirectToSignInPage();
|
|
582
547
|
const {
|
|
583
548
|
authenticationState,
|
|
584
549
|
user
|
|
585
|
-
} = yield
|
|
550
|
+
} = yield login.LoginUser({
|
|
586
551
|
username,
|
|
587
552
|
password,
|
|
588
553
|
clientCredentials
|
|
@@ -593,46 +558,42 @@ function* loginUserSaga(action = {}) {
|
|
|
593
558
|
user
|
|
594
559
|
});
|
|
595
560
|
}
|
|
596
|
-
|
|
597
561
|
const removeHostnamePart = path => {
|
|
598
562
|
// eslint-disable-next-line no-console
|
|
599
563
|
console.log(path);
|
|
600
|
-
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
601
|
-
|
|
564
|
+
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
565
|
+
// eslint-disable-next-line no-console
|
|
602
566
|
console.log(relativePath);
|
|
603
567
|
return relativePath;
|
|
604
568
|
};
|
|
605
|
-
|
|
606
569
|
function* redirectAfterSuccessfulLoginSaga() {
|
|
607
570
|
const isLoggedIn = yield effects.select(ToJs.selectUserIsAuthenticated);
|
|
608
571
|
const {
|
|
609
572
|
redirect_uri: redirectPath,
|
|
610
573
|
ReturnURL: assetRedirectPath
|
|
611
574
|
} = selectors.queryParams(yield effects.select(selectors.selectCurrentSearch));
|
|
612
|
-
|
|
613
575
|
if (isLoggedIn && assetRedirectPath && typeof window != 'undefined') {
|
|
614
|
-
const path = removeHostnamePart(assetRedirectPath);
|
|
576
|
+
const path = removeHostnamePart(assetRedirectPath);
|
|
577
|
+
// This has to be a hard href to get the app to
|
|
615
578
|
// leave React and hit the server for the IIS hosted assets
|
|
616
|
-
|
|
617
|
-
|
|
579
|
+
window.location.href = path;
|
|
580
|
+
// yield put(setRoute(path)); // does not work in this scenario
|
|
618
581
|
} else if (isLoggedIn && redirectPath) {
|
|
619
|
-
yield effects.put(
|
|
582
|
+
yield effects.put(selectors.setRoute(redirectPath));
|
|
620
583
|
}
|
|
621
584
|
}
|
|
622
|
-
|
|
623
585
|
function* logoutUserSaga({
|
|
624
|
-
redirectPath
|
|
586
|
+
redirectPath,
|
|
587
|
+
cookies
|
|
625
588
|
}) {
|
|
626
589
|
yield effects.put({
|
|
627
590
|
type: reducers.SET_AUTHENTICATION_STATE,
|
|
628
591
|
user: null
|
|
629
592
|
});
|
|
630
|
-
yield LoginHelper.LogoutUser(redirectPath);
|
|
593
|
+
yield LoginHelper.withCookies(cookies).LogoutUser(redirectPath);
|
|
631
594
|
}
|
|
632
|
-
|
|
633
595
|
function* refreshSecurityToken() {
|
|
634
596
|
const clientCredentials = yield effects.select(ToJs.selectClientCredentials, 'js');
|
|
635
|
-
|
|
636
597
|
if (Object.keys(clientCredentials).length > 0) {
|
|
637
598
|
const client = yield getManagementApiClient(clientCredentials);
|
|
638
599
|
yield client.authenticate();
|
|
@@ -645,10 +606,162 @@ function* refreshSecurityToken() {
|
|
|
645
606
|
}
|
|
646
607
|
}
|
|
647
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;
|
|
648
751
|
exports.LoginHelper = LoginHelper;
|
|
752
|
+
exports.Login_container = Login_container;
|
|
753
|
+
exports.Registration_container = Registration_container;
|
|
754
|
+
exports.actions = actions;
|
|
649
755
|
exports.findContentTypeMapping = findContentTypeMapping;
|
|
650
756
|
exports.getManagementApiClient = getManagementApiClient;
|
|
651
757
|
exports.handleRequiresLoginSaga = handleRequiresLoginSaga;
|
|
652
758
|
exports.loginSagas = loginSagas;
|
|
759
|
+
exports.loginUser = loginUser;
|
|
760
|
+
exports.logoutUser = logoutUser;
|
|
653
761
|
exports.refreshSecurityToken = refreshSecurityToken;
|
|
654
|
-
|
|
762
|
+
exports.registerUser = registerUser;
|
|
763
|
+
exports.useChangePassword = useChangePassword;
|
|
764
|
+
exports.useForgotPassword = useForgotPassword;
|
|
765
|
+
exports.useLogin = useLogin;
|
|
766
|
+
exports.useRegistration = useRegistration;
|
|
767
|
+
//# sourceMappingURL=ChangePassword.container-a617190b.js.map
|