@zengenti/contensis-react-base 4.0.0-beta.2 → 4.0.0-beta.3
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/LICENSE +7 -0
- package/README.md +18 -478
- package/cjs/{App-b56aca04.js → App-BNcmM8rN.js} +215 -234
- package/cjs/App-BNcmM8rN.js.map +1 -0
- package/cjs/{ChangePassword.container-ae35785e.js → ChangePassword.container-642SYfpS.js} +209 -286
- package/cjs/ChangePassword.container-642SYfpS.js.map +1 -0
- package/cjs/CookieHelper.class-BoY5TrIi.js +562 -0
- package/cjs/CookieHelper.class-BoY5TrIi.js.map +1 -0
- package/cjs/{RouteLoader-c06dccd5.js → RouteLoader-DvyYYyIE.js} +55 -68
- package/cjs/RouteLoader-DvyYYyIE.js.map +1 -0
- package/cjs/{ContensisDeliveryApi-4fcf049d.js → SSRContext-D66GKlH7.js} +165 -119
- package/cjs/SSRContext-D66GKlH7.js.map +1 -0
- package/cjs/{ToJs-a8d8f3f0.js → ToJs-C9jwV7YB.js} +26 -80
- package/cjs/ToJs-C9jwV7YB.js.map +1 -0
- package/cjs/{_commonjsHelpers-b3309d7b.js → _commonjsHelpers-BJu3ubxk.js} +1 -1
- package/cjs/_commonjsHelpers-BJu3ubxk.js.map +1 -0
- package/cjs/client.js +67 -65
- package/cjs/client.js.map +1 -1
- package/cjs/contensis-react-base.js +386 -3293
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/{fromJSLeaveImmer-e74c673c.js → fromJSLeaveImmer-Blvlk4t2.js} +3 -7
- package/{esm/fromJSLeaveImmer-0114ffcf.js.map → cjs/fromJSLeaveImmer-Blvlk4t2.js.map} +1 -1
- package/cjs/redux.js +18 -19
- package/cjs/redux.js.map +1 -1
- package/cjs/routing.js +13 -6
- package/cjs/routing.js.map +1 -1
- package/cjs/sagas-CbZhaRNd.js +6010 -0
- package/cjs/sagas-CbZhaRNd.js.map +1 -0
- package/cjs/search.js +105 -305
- package/cjs/search.js.map +1 -1
- package/cjs/selectors-wCs5fHD4.js +460 -0
- package/cjs/selectors-wCs5fHD4.js.map +1 -0
- package/cjs/{version-34d91f68.js → store-CADDS7cV.js} +44 -111
- package/cjs/store-CADDS7cV.js.map +1 -0
- package/cjs/{urls-6fcaf4c6.js → urls-DVIwGZmd.js} +1 -1
- package/{esm/urls-eac9a747.js.map → cjs/urls-DVIwGZmd.js.map} +1 -1
- package/cjs/user.js +12 -20
- package/cjs/user.js.map +1 -1
- package/cjs/util.js +108 -115
- package/cjs/util.js.map +1 -1
- package/cjs/{version-a410c88e.js → version-ASZx0NDG.js} +19 -22
- package/{esm/version-9f29becb.js.map → cjs/version-ASZx0NDG.js.map} +1 -1
- package/cjs/version-CM-bJ62L.js +20 -0
- package/cjs/version-CM-bJ62L.js.map +1 -0
- package/esm/{App-83107d7e.js → App-CfIZbvU9.js} +176 -195
- package/esm/App-CfIZbvU9.js.map +1 -0
- package/esm/{ChangePassword.container-76fd5e9b.js → ChangePassword.container-Q7bElOVz.js} +191 -250
- package/esm/ChangePassword.container-Q7bElOVz.js.map +1 -0
- package/esm/CookieHelper.class-DzleKOOc.js +555 -0
- package/esm/CookieHelper.class-DzleKOOc.js.map +1 -0
- package/esm/{RouteLoader-29fd689a.js → RouteLoader-qJA3UqTM.js} +40 -53
- package/esm/RouteLoader-qJA3UqTM.js.map +1 -0
- package/esm/{ContensisDeliveryApi-fe57a037.js → SSRContext-C743Oeli.js} +159 -120
- package/esm/SSRContext-C743Oeli.js.map +1 -0
- package/esm/{ToJs-df57f31d.js → ToJs-CpPNdcXS.js} +24 -77
- package/esm/ToJs-CpPNdcXS.js.map +1 -0
- package/esm/{_commonjsHelpers-1789f0cf.js → _commonjsHelpers-BFTU3MAI.js} +1 -1
- package/esm/_commonjsHelpers-BFTU3MAI.js.map +1 -0
- package/esm/client.js +55 -53
- package/esm/client.js.map +1 -1
- package/esm/contensis-react-base.js +317 -3222
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/{fromJSLeaveImmer-0114ffcf.js → fromJSLeaveImmer-C_YACmOf.js} +2 -6
- package/{cjs/fromJSLeaveImmer-e74c673c.js.map → esm/fromJSLeaveImmer-C_YACmOf.js.map} +1 -1
- package/esm/redux.js +9 -8
- package/esm/redux.js.map +1 -1
- package/esm/routing.js +13 -4
- package/esm/routing.js.map +1 -1
- package/esm/sagas-xJU-zOpn.js +5916 -0
- package/esm/sagas-xJU-zOpn.js.map +1 -0
- package/esm/search.js +113 -311
- package/esm/search.js.map +1 -1
- package/esm/selectors-CBdCY0u3.js +396 -0
- package/esm/selectors-CBdCY0u3.js.map +1 -0
- package/esm/{version-3d9911e2.js → store-uQZKjfA8.js} +36 -81
- package/esm/store-uQZKjfA8.js.map +1 -0
- package/esm/{urls-eac9a747.js → urls-DfCisos-.js} +1 -1
- package/{cjs/urls-6fcaf4c6.js.map → esm/urls-DfCisos-.js.map} +1 -1
- package/esm/user.js +7 -13
- package/esm/user.js.map +1 -1
- package/esm/util.js +66 -74
- package/esm/util.js.map +1 -1
- package/esm/{version-9f29becb.js → version-B9nPx4IF.js} +6 -9
- package/{cjs/version-a410c88e.js.map → esm/version-B9nPx4IF.js.map} +1 -1
- package/esm/version-D773TD9j.js +15 -0
- package/esm/version-D773TD9j.js.map +1 -0
- package/models/app/App.d.ts +1 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.d.ts +1 -1
- package/models/app/pages/VersionInfo/components/VersionInfo.styled.d.ts +2 -1
- package/models/client/client.d.ts +1 -1
- package/models/index.d.ts +1 -2
- package/models/models/AppRouteProps.d.ts +11 -0
- package/models/models/ContentTypeMapping.d.ts +89 -0
- package/models/models/EntryMapper.d.ts +3 -0
- package/models/models/GetRouteActionArgs.d.ts +15 -0
- package/models/models/MatchedRoute.d.ts +4 -0
- package/models/models/ReduxInjector.d.ts +5 -0
- package/models/models/RequireLogin.d.ts +6 -0
- package/models/models/RouteComponent.d.ts +4 -0
- package/models/models/RouteComponentProps.d.ts +9 -0
- package/models/models/RouteLoaderProps.d.ts +9 -0
- package/models/models/RouteNode.d.ts +5 -0
- package/models/models/SSRContext.d.ts +11 -0
- package/models/models/StaticRoute.d.ts +60 -0
- package/models/models/WithEvents.d.ts +58 -0
- package/models/models/config/AppConfig.d.ts +12 -0
- package/models/{config.d.ts → models/config/ServerConfig.d.ts} +3 -12
- package/models/models/config/StateType.d.ts +1 -0
- package/models/models/config/index.d.ts +3 -0
- package/models/models/index.d.ts +16 -0
- package/models/redux/actions/index.d.ts +2 -2
- package/models/redux/sagas/navigation.d.ts +1 -3
- package/models/redux/selectors/index.d.ts +2 -2
- package/models/redux/store/injectors.d.ts +16 -4
- package/models/redux/store/store.d.ts +10 -4
- package/models/redux/types/index.d.ts +2 -2
- package/models/redux/types/navigation.d.ts +3 -3
- package/models/redux/types/version.d.ts +2 -2
- package/models/routing/components/Redirect.d.ts +1 -1
- package/models/routing/components/RouteLoader.d.ts +1 -1
- package/models/routing/components/StaticRouteLoader.d.ts +1 -1
- package/models/routing/components/Status.d.ts +1 -1
- package/models/routing/redux/actions.d.ts +3 -4
- package/models/routing/redux/selectors.d.ts +2 -2
- package/models/routing/redux/types.d.ts +11 -11
- package/models/routing/routes.d.ts +1 -1
- package/models/routing/util/find-contenttype-mapping.d.ts +1 -1
- package/models/routing/util/queries.d.ts +2 -2
- package/models/search/models/Queries.d.ts +4 -2
- package/models/search/models/Search.d.ts +8 -1
- package/models/search/models/SearchActions.d.ts +3 -2
- package/models/search/models/SearchState.d.ts +5 -1
- package/models/search/redux/reducers.d.ts +2 -257
- package/models/search/redux/schema.d.ts +1 -1
- package/models/search/redux/selectors.d.ts +5 -5
- package/models/search/search/ContensisDeliveryApi.d.ts +2 -2
- package/models/search/search/ToJs.d.ts +1 -1
- package/models/search/search/expressions.d.ts +3 -3
- package/models/search/search/util.d.ts +17 -2
- package/models/search/transformations/searchresult-to-state.mapper.d.ts +1 -2
- package/models/server/features/caching/cacheDuration.schema.d.ts +1 -0
- package/models/server/features/linkdepth-api/search.d.ts +1 -1
- package/models/server/features/static-assets/index.d.ts +1 -1
- package/models/server/internalServer.d.ts +1 -1
- package/models/server/util/bundles.d.ts +1 -1
- package/models/server/util/headers.d.ts +1 -1
- package/models/server/webApp.d.ts +1 -1
- package/models/user/components/Login.d.ts +1 -1
- package/models/user/components/LoginForm.d.ts +6 -6
- package/models/user/components/LogoutForm.d.ts +4 -4
- package/models/user/components.styled/Login.styled.d.ts +1 -1
- package/models/user/components.styled/LoginForm.styled.d.ts +1 -1
- package/models/user/hocs/withLogin.d.ts +4 -4
- package/models/user/hooks/useLogin.d.ts +4 -4
- package/models/user/redux/actions.d.ts +7 -6
- package/models/user/redux/sagas/index.d.ts +1 -1
- package/models/user/redux/sagas/login.d.ts +5 -17
- package/models/user/redux/selectors.d.ts +1 -2
- package/models/user/redux/types.d.ts +21 -21
- package/models/user/state.d.ts +12 -0
- package/models/user/transformations/mapClientCredentials.d.ts +3 -1
- package/models/user/util/ContensisManagementApi.d.ts +10 -9
- package/models/user/util/CookieConstants.d.ts +1 -0
- package/models/user/util/CookieHelper.class.d.ts +8 -4
- package/models/user/util/LoginHelper.class.d.ts +25 -37
- package/models/user/util/OidcUserManager.d.ts +1 -1
- package/models/user/util/matchGroups.d.ts +1 -1
- package/models/util/CachedDeliveryApi.d.ts +11 -10
- package/models/util/ContensisDeliveryApi.d.ts +11 -7
- package/models/util/SSRContext.d.ts +29 -0
- package/models/util/index.d.ts +1 -0
- package/models/util/json-mapper.d.ts +4 -5
- package/package.json +71 -92
- package/cjs/App-b56aca04.js.map +0 -1
- package/cjs/ChangePassword.container-ae35785e.js.map +0 -1
- package/cjs/ContensisDeliveryApi-4fcf049d.js.map +0 -1
- package/cjs/CookieConstants-000427db.js +0 -10
- package/cjs/CookieConstants-000427db.js.map +0 -1
- package/cjs/RouteLoader-c06dccd5.js.map +0 -1
- package/cjs/ToJs-a8d8f3f0.js.map +0 -1
- package/cjs/_commonjsHelpers-b3309d7b.js.map +0 -1
- package/cjs/forms.js +0 -5998
- package/cjs/forms.js.map +0 -1
- package/cjs/reducers-73a03ef4.js +0 -257
- package/cjs/reducers-73a03ef4.js.map +0 -1
- package/cjs/sagas-570f23ba.js +0 -2175
- package/cjs/sagas-570f23ba.js.map +0 -1
- package/cjs/selectors-14caa813.js +0 -228
- package/cjs/selectors-14caa813.js.map +0 -1
- package/cjs/version-34d91f68.js.map +0 -1
- package/esm/App-83107d7e.js.map +0 -1
- package/esm/ChangePassword.container-76fd5e9b.js.map +0 -1
- package/esm/ContensisDeliveryApi-fe57a037.js.map +0 -1
- package/esm/CookieConstants-3d3b6531.js +0 -6
- package/esm/CookieConstants-3d3b6531.js.map +0 -1
- package/esm/RouteLoader-29fd689a.js.map +0 -1
- package/esm/ToJs-df57f31d.js.map +0 -1
- package/esm/_commonjsHelpers-1789f0cf.js.map +0 -1
- package/esm/forms.js +0 -5984
- package/esm/forms.js.map +0 -1
- package/esm/reducers-aa8cef1e.js +0 -234
- package/esm/reducers-aa8cef1e.js.map +0 -1
- package/esm/sagas-07e82e18.js +0 -2083
- package/esm/sagas-07e82e18.js.map +0 -1
- package/esm/selectors-691caf02.js +0 -186
- package/esm/selectors-691caf02.js.map +0 -1
- package/esm/version-3d9911e2.js.map +0 -1
- package/models/forms/index.d.ts +0 -1
- /package/models/{redux/appstate.d.ts → models/AppState.d.ts} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { takeEvery, put, call, select } from '@redux-saga/core/effects';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { q as queryParams, o as selectCurrentSearch, p as setRoute, E as action } from './selectors-691caf02.js';
|
|
2
|
+
import { $ as LOGIN_USER, a0 as LOGOUT_USER, a1 as VALIDATE_USER, a2 as SET_AUTHENTICATION_STATE, J as queryParams, K as selectCurrentSearch, L as setRoute, c as action, R as REGISTER_USER, M as REQUEST_USER_PASSWORD_RESET, N as RESET_USER_PASSWORD, O as CHANGE_USER_PASSWORD } from './selectors-CBdCY0u3.js';
|
|
3
|
+
import { d as selectUserIsAuthenticated, k as selectUserGroups, m as matchUserGroup, l as selectClientCredentials, s as selectUserIsError, e as selectUserErrorMessage, a as selectUserIsAuthenticationError, b as selectUser, c as selectUserIsLoading, t as toJS, f as selectUserRegistration, g as selectUserRegistrationIsSuccess, h as selectUserRegistrationIsLoading, i as selectUserRegistrationError, n as selectResetPasswordError, o as selectResetPasswordSent, p as selectResetPasswordSending, q as selectPasswordResetRequestError, r as selectPasswordResetRequestSent, u as selectPasswordResetRequestSending, v as selectChangePasswordError, w as selectUserGuid, x as selectChangePasswordSent, y as selectChangePasswordSending } from './ToJs-CpPNdcXS.js';
|
|
5
4
|
import mapJson from 'jsonpath-mapper';
|
|
6
5
|
import { to } from 'await-to-js';
|
|
7
|
-
import { L as LOGIN_COOKIE, R as REFRESH_TOKEN_COOKIE } from './
|
|
6
|
+
import { C as CookieHelper, B as BEARER_TOKEN_COOKIE, L as LOGIN_COOKIE, R as REFRESH_TOKEN_COOKIE } from './CookieHelper.class-DzleKOOc.js';
|
|
8
7
|
import { useCookies } from 'react-cookie';
|
|
9
8
|
import { useDispatch, useSelector } from 'react-redux';
|
|
10
9
|
|
|
@@ -21,9 +20,8 @@ const clientCredentials = {
|
|
|
21
20
|
}) => refreshTokenExpiryDate.toISOString(),
|
|
22
21
|
contensisClassicToken: 'contensisClassicToken'
|
|
23
22
|
};
|
|
24
|
-
var mapClientCredentials =
|
|
23
|
+
var mapClientCredentials = obj => mapJson(obj, clientCredentials);
|
|
25
24
|
|
|
26
|
-
// import { Client } from 'contensis-management-api';
|
|
27
25
|
const getManagementApiClient = async ({
|
|
28
26
|
bearerToken,
|
|
29
27
|
bearerTokenExpiryDate,
|
|
@@ -33,14 +31,10 @@ const getManagementApiClient = async ({
|
|
|
33
31
|
username,
|
|
34
32
|
password
|
|
35
33
|
}) => {
|
|
36
|
-
const rootUrl = SERVERS.
|
|
37
|
-
/* global
|
|
38
|
-
|
|
39
|
-
const projectId = PROJECTS[0].id;
|
|
40
|
-
/* global PROJECTS */
|
|
34
|
+
const rootUrl = SERVERS.cms || SERVERS.api; /* global SERVERS */
|
|
35
|
+
const projectId = PROJECTS[0].id; /* global PROJECTS */
|
|
41
36
|
|
|
42
37
|
let config = {};
|
|
43
|
-
|
|
44
38
|
if (refreshToken) {
|
|
45
39
|
config = {
|
|
46
40
|
clientType: 'contensis_classic_refresh_token',
|
|
@@ -57,19 +51,17 @@ const getManagementApiClient = async ({
|
|
|
57
51
|
}
|
|
58
52
|
};
|
|
59
53
|
}
|
|
60
|
-
|
|
61
54
|
let {
|
|
62
55
|
Client
|
|
63
56
|
} = await import('contensis-management-api');
|
|
64
|
-
|
|
65
57
|
if (typeof window === 'undefined') {
|
|
66
58
|
const {
|
|
67
59
|
UniversalClient
|
|
68
60
|
} = await import('contensis-management-api');
|
|
69
61
|
Client = UniversalClient;
|
|
70
62
|
}
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
const client = Client.create({
|
|
64
|
+
...config,
|
|
73
65
|
projectId,
|
|
74
66
|
rootUrl
|
|
75
67
|
});
|
|
@@ -82,11 +74,8 @@ const getManagementApiClient = async ({
|
|
|
82
74
|
};
|
|
83
75
|
|
|
84
76
|
const context$1 = typeof window != 'undefined' ? window : global;
|
|
85
|
-
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
86
|
-
/* global
|
|
87
|
-
: context$1.WSFED_LOGIN === 'true';
|
|
88
|
-
const servers = SERVERS;
|
|
89
|
-
/* global SERVERS */
|
|
77
|
+
const requireOidc = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context$1.WSFED_LOGIN === 'true';
|
|
78
|
+
const servers = SERVERS; /* global SERVERS */
|
|
90
79
|
|
|
91
80
|
const userManagerConfig = typeof window !== 'undefined' ? {
|
|
92
81
|
authority: `${servers.cms}/authenticate/`,
|
|
@@ -102,162 +91,23 @@ const createUserManager = async config => {
|
|
|
102
91
|
try {
|
|
103
92
|
const {
|
|
104
93
|
UserManager
|
|
105
|
-
} = await import(
|
|
106
|
-
/* webpackChunkName: "oidcclient" */
|
|
107
|
-
'oidc-client');
|
|
94
|
+
} = await import(/* webpackChunkName: "oidcclient" */'oidc-client');
|
|
108
95
|
return new UserManager(config);
|
|
109
96
|
} catch (e) {
|
|
110
97
|
console.error('Exception in createUserManager: ', e);
|
|
111
98
|
}
|
|
112
|
-
} else return
|
|
99
|
+
} else return;
|
|
113
100
|
};
|
|
114
101
|
|
|
115
|
-
|
|
102
|
+
var _LoginHelper;
|
|
116
103
|
const context = typeof window != 'undefined' ? window : global;
|
|
117
104
|
class LoginHelper {
|
|
118
105
|
constructor(cookies) {
|
|
119
|
-
this.cookies =
|
|
120
|
-
this.cookies = cookies;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
SetLoginCookies({
|
|
124
|
-
contensisClassicToken,
|
|
125
|
-
refreshToken
|
|
126
|
-
}) {
|
|
127
|
-
console.info('SetLoginCookies:', LOGIN_COOKIE, contensisClassicToken, REFRESH_TOKEN_COOKIE, refreshToken);
|
|
128
|
-
if (contensisClassicToken) this.cookies.SetCookie(LOGIN_COOKIE, contensisClassicToken);
|
|
129
|
-
if (refreshToken) this.cookies.SetCookie(REFRESH_TOKEN_COOKIE, refreshToken);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
GetCachedCredentials() {
|
|
133
|
-
return {
|
|
134
|
-
bearerToken: null,
|
|
135
|
-
bearerTokenExpiryDate: null,
|
|
136
|
-
refreshToken: this.cookies.GetCookie(REFRESH_TOKEN_COOKIE),
|
|
137
|
-
refreshTokenExpiryDate: null,
|
|
138
|
-
contensisClassicToken: this.cookies.GetCookie(LOGIN_COOKIE)
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
ClearCachedCredentials() {
|
|
143
|
-
this.cookies.DeleteCookie(LOGIN_COOKIE);
|
|
144
|
-
this.cookies.DeleteCookie(REFRESH_TOKEN_COOKIE);
|
|
145
|
-
|
|
146
|
-
if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
|
|
147
|
-
// remove any oidc keys left over in localStorage
|
|
148
|
-
const {
|
|
149
|
-
localStorage
|
|
150
|
-
} = window;
|
|
151
|
-
const keys = [];
|
|
152
|
-
|
|
153
|
-
for (let i = 0; i < localStorage.length; i++) {
|
|
154
|
-
const key = localStorage.key(i);
|
|
155
|
-
if (typeof key === 'string' && key.startsWith('oidc.')) keys.push(localStorage.key(i));
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
keys.forEach(key => localStorage.removeItem(key));
|
|
159
|
-
}
|
|
106
|
+
this.cookies = cookies || new CookieHelper();
|
|
160
107
|
}
|
|
161
|
-
|
|
162
|
-
async LoginUser({
|
|
163
|
-
username,
|
|
164
|
-
password,
|
|
165
|
-
clientCredentials
|
|
166
|
-
}) {
|
|
167
|
-
let credentials = clientCredentials;
|
|
168
|
-
let authenticationState = {
|
|
169
|
-
clientCredentials: null,
|
|
170
|
-
isAuthenticated: false,
|
|
171
|
-
isAuthenticationError: false,
|
|
172
|
-
isError: false
|
|
173
|
-
};
|
|
174
|
-
let transientClient;
|
|
175
|
-
let user;
|
|
176
|
-
|
|
177
|
-
if (username && password) {
|
|
178
|
-
// Get a management client with username and password
|
|
179
|
-
transientClient = await getManagementApiClient({
|
|
180
|
-
username,
|
|
181
|
-
password
|
|
182
|
-
}); // Ensure the client has requested a bearer token
|
|
183
|
-
|
|
184
|
-
const [loginError, clientBearerToken] = await to(transientClient.ensureBearerToken()); // Problem getting token with username and password
|
|
185
|
-
|
|
186
|
-
if (loginError) {
|
|
187
|
-
authenticationState = {
|
|
188
|
-
clientCredentials: null,
|
|
189
|
-
errorMessage: loginError.message || null,
|
|
190
|
-
isAuthenticated: false,
|
|
191
|
-
isAuthenticationError: loginError.name.includes('ContensisAuthenticationError'),
|
|
192
|
-
isError: true
|
|
193
|
-
};
|
|
194
|
-
this.ClearCachedCredentials();
|
|
195
|
-
} // Got a token using username and password
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
if (clientBearerToken) {
|
|
199
|
-
// Set credentials so we can continue to GetUserDetails
|
|
200
|
-
credentials = mapClientCredentials(transientClient);
|
|
201
|
-
this.SetLoginCookies(credentials);
|
|
202
|
-
authenticationState = {
|
|
203
|
-
clientCredentials: credentials,
|
|
204
|
-
isAuthenticated: true,
|
|
205
|
-
isAuthenticationError: false,
|
|
206
|
-
isError: false
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
} // If we have credentials supplied by a successful username and password login
|
|
210
|
-
// or clientCredentials supplied in the options argument we can continue to
|
|
211
|
-
// fetch the user's details
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (credentials) {
|
|
215
|
-
const client = transientClient || (await getManagementApiClient(credentials));
|
|
216
|
-
const [error, userDetails] = await LoginHelper.GetUserDetails(client);
|
|
217
|
-
|
|
218
|
-
if (error) {
|
|
219
|
-
authenticationState = {
|
|
220
|
-
clientCredentials: null,
|
|
221
|
-
errorMessage: error.message,
|
|
222
|
-
isAuthenticated: false,
|
|
223
|
-
isAuthenticationError: false,
|
|
224
|
-
isError: true
|
|
225
|
-
};
|
|
226
|
-
this.ClearCachedCredentials();
|
|
227
|
-
} else {
|
|
228
|
-
// Ensure we get latest refreshToken and contensisClassicToken from the latest client
|
|
229
|
-
const latestCredentials = mapClientCredentials(client);
|
|
230
|
-
this.SetLoginCookies(latestCredentials);
|
|
231
|
-
user = userDetails;
|
|
232
|
-
authenticationState = {
|
|
233
|
-
clientCredentials: latestCredentials,
|
|
234
|
-
isAuthenticated: true,
|
|
235
|
-
isAuthenticationError: false,
|
|
236
|
-
isError: false
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return {
|
|
242
|
-
authenticationState,
|
|
243
|
-
user
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
LogoutUser(redirectPath) {
|
|
248
|
-
this.ClearCachedCredentials();
|
|
249
|
-
|
|
250
|
-
if (LoginHelper.WSFED_LOGIN) {
|
|
251
|
-
LoginHelper.WsFedLogout(redirectPath);
|
|
252
|
-
} else {
|
|
253
|
-
if (redirectPath) LoginHelper.ClientRedirectToPath(redirectPath);else LoginHelper.ClientRedirectToSignInPage();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
108
|
static ClientRedirectToHome(location) {
|
|
258
109
|
if (typeof window != 'undefined') {
|
|
259
110
|
let url = '/';
|
|
260
|
-
|
|
261
111
|
if (location) {
|
|
262
112
|
const {
|
|
263
113
|
search,
|
|
@@ -266,14 +116,11 @@ class LoginHelper {
|
|
|
266
116
|
url = search ? `${url}${search}` : url;
|
|
267
117
|
url = hash ? `${url}${hash}` : url;
|
|
268
118
|
}
|
|
269
|
-
|
|
270
119
|
window.location.href = url;
|
|
271
120
|
}
|
|
272
121
|
}
|
|
273
|
-
|
|
274
122
|
static async ClientRedirectToSignInPage(redirectPath) {
|
|
275
123
|
if (typeof location === 'undefined') return;
|
|
276
|
-
|
|
277
124
|
if (LoginHelper.WSFED_LOGIN) {
|
|
278
125
|
await LoginHelper.WsFedLogout();
|
|
279
126
|
await LoginHelper.WsFedLogin();
|
|
@@ -284,56 +131,47 @@ class LoginHelper {
|
|
|
284
131
|
if (typeof location !== 'undefined' && redirectPath !== LoginHelper.LOGIN_ROUTE) location.replace(url);
|
|
285
132
|
}
|
|
286
133
|
}
|
|
287
|
-
|
|
288
134
|
static GetAccessDeniedRoute(originalPath) {
|
|
289
135
|
let url = LoginHelper.ACCESS_DENIED_ROUTE;
|
|
290
136
|
if (originalPath !== url && typeof originalPath === 'string') url = `${url}?original_uri=${originalPath}`;
|
|
291
137
|
return url;
|
|
292
138
|
}
|
|
293
|
-
|
|
294
139
|
static ClientRedirectToAccessDeniedPage(originalPath) {
|
|
295
140
|
if (typeof location !== 'undefined') location.href = LoginHelper.GetAccessDeniedRoute(originalPath);
|
|
296
141
|
}
|
|
297
|
-
|
|
298
142
|
static ClientRedirectToPath(redirectPath) {
|
|
299
143
|
if (typeof redirectPath === 'string') {
|
|
300
144
|
if (typeof location !== 'undefined') window.location.href = redirectPath;
|
|
301
145
|
} else LoginHelper.ClientRedirectToHome();
|
|
302
146
|
}
|
|
303
|
-
|
|
304
147
|
static async WsFedLogin(redirectUri) {
|
|
305
148
|
const userManager = await createUserManager(userManagerConfig);
|
|
306
|
-
userManager.signinRedirect({
|
|
149
|
+
userManager === null || userManager === void 0 || userManager.signinRedirect({
|
|
307
150
|
scope: 'openid',
|
|
308
151
|
response_type: 'id_token',
|
|
309
152
|
redirect_uri: redirectUri || window.location.toString()
|
|
310
153
|
});
|
|
311
154
|
}
|
|
312
|
-
|
|
313
155
|
static RemoveSecurityTokenQuery() {
|
|
314
156
|
const params = new URLSearchParams(window.location.search);
|
|
315
|
-
|
|
316
157
|
if (params.has('securitytoken') || params.has('securityToken')) {
|
|
317
158
|
params.delete('securitytoken');
|
|
318
159
|
params.delete('securityToken');
|
|
319
|
-
window.location = `${window.location.pathname}${params.toString() ? `?${params}` : ''}`;
|
|
160
|
+
window.location.href = `${window.location.pathname}${params.toString() ? `?${params}` : ''}`;
|
|
320
161
|
}
|
|
321
162
|
}
|
|
322
|
-
|
|
323
163
|
static async WsFedLogout(redirectPath) {
|
|
324
164
|
await fetch(`${LoginHelper.CMS_URL}/authenticate/logout?jsonResponseRequired=true`, {
|
|
325
165
|
credentials: 'include'
|
|
326
166
|
});
|
|
327
|
-
|
|
328
167
|
if (redirectPath) {
|
|
329
|
-
window.location = redirectPath;
|
|
168
|
+
window.location.href = redirectPath;
|
|
330
169
|
} else {
|
|
331
170
|
// Explicitly check and remove any stale
|
|
332
171
|
// security token that may be in the query string
|
|
333
172
|
LoginHelper.RemoveSecurityTokenQuery();
|
|
334
173
|
}
|
|
335
174
|
}
|
|
336
|
-
|
|
337
175
|
static async GetCredentialsForSecurityToken(securityToken) {
|
|
338
176
|
const [error, response] = await to(fetch(`${LoginHelper.CMS_URL}/REST/Contensis/Security/IsAuthenticated`, {
|
|
339
177
|
method: 'POST',
|
|
@@ -348,7 +186,6 @@ class LoginHelper {
|
|
|
348
186
|
if (error) return [{
|
|
349
187
|
message: 'Failed to fetch credentials'
|
|
350
188
|
}];
|
|
351
|
-
|
|
352
189
|
if (response.ok) {
|
|
353
190
|
const [parseError, body] = await to(response.json());
|
|
354
191
|
if (parseError) return [parseError];
|
|
@@ -356,7 +193,6 @@ class LoginHelper {
|
|
|
356
193
|
LogonResult,
|
|
357
194
|
ApplicationData = []
|
|
358
195
|
} = body;
|
|
359
|
-
|
|
360
196
|
if (LogonResult !== 0) {
|
|
361
197
|
console.info(`Security token is invalid - LogonResult: ${LogonResult}`);
|
|
362
198
|
return [{
|
|
@@ -364,19 +200,16 @@ class LoginHelper {
|
|
|
364
200
|
data: ApplicationData
|
|
365
201
|
}];
|
|
366
202
|
}
|
|
367
|
-
|
|
368
203
|
if (ApplicationData.length > 0) {
|
|
369
204
|
let refreshToken;
|
|
370
205
|
ApplicationData.forEach(item => {
|
|
371
206
|
if (item.Key === 'ContensisSecurityRefreshToken') refreshToken = item.Value;
|
|
372
207
|
});
|
|
373
|
-
|
|
374
208
|
if (!refreshToken) {
|
|
375
209
|
return [{
|
|
376
210
|
message: 'Fetch credentials: Unable to find ContensisSecurityRefreshToken'
|
|
377
211
|
}];
|
|
378
212
|
}
|
|
379
|
-
|
|
380
213
|
return [undefined, refreshToken];
|
|
381
214
|
} else {
|
|
382
215
|
return [{
|
|
@@ -388,8 +221,11 @@ class LoginHelper {
|
|
|
388
221
|
message: `Fetch credentials error: ${response.status} ${response.statusText}`
|
|
389
222
|
}];
|
|
390
223
|
}
|
|
391
|
-
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// static isZengentiStaff(email) {
|
|
392
227
|
// const emailRefs = ['@zengenti', '@contensis'];
|
|
228
|
+
|
|
393
229
|
// return emailRefs.some(emailRef => {
|
|
394
230
|
// if (email.includes(emailRef)) {
|
|
395
231
|
// return true;
|
|
@@ -397,49 +233,166 @@ class LoginHelper {
|
|
|
397
233
|
// });
|
|
398
234
|
// }
|
|
399
235
|
|
|
236
|
+
SetLoginCookies({
|
|
237
|
+
bearerToken,
|
|
238
|
+
contensisClassicToken,
|
|
239
|
+
refreshToken
|
|
240
|
+
}) {
|
|
241
|
+
if (bearerToken) this.cookies.SetCookie(BEARER_TOKEN_COOKIE, bearerToken);
|
|
242
|
+
if (contensisClassicToken) this.cookies.SetCookie(LOGIN_COOKIE, contensisClassicToken);
|
|
243
|
+
if (refreshToken) this.cookies.SetCookie(REFRESH_TOKEN_COOKIE, refreshToken);
|
|
244
|
+
}
|
|
245
|
+
GetCachedCredentials() {
|
|
246
|
+
return {
|
|
247
|
+
bearerToken: null,
|
|
248
|
+
bearerTokenExpiryDate: null,
|
|
249
|
+
refreshToken: this.cookies.GetCookie(REFRESH_TOKEN_COOKIE),
|
|
250
|
+
refreshTokenExpiryDate: null,
|
|
251
|
+
contensisClassicToken: this.cookies.GetCookie(LOGIN_COOKIE),
|
|
252
|
+
securityToken: null
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
ClearCachedCredentials() {
|
|
256
|
+
this.cookies.DeleteCookie(LOGIN_COOKIE);
|
|
257
|
+
this.cookies.DeleteCookie(REFRESH_TOKEN_COOKIE);
|
|
258
|
+
this.cookies.DeleteCookie(BEARER_TOKEN_COOKIE); // additional cookie used by @contensis/forms package
|
|
259
|
+
|
|
260
|
+
if (LoginHelper.WSFED_LOGIN && typeof window !== 'undefined') {
|
|
261
|
+
// remove any oidc keys left over in localStorage
|
|
262
|
+
const {
|
|
263
|
+
localStorage
|
|
264
|
+
} = window;
|
|
265
|
+
const keys = [];
|
|
266
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
267
|
+
const key = localStorage.key(i);
|
|
268
|
+
if (typeof key === 'string' && key.startsWith('oidc.')) keys.push(key);
|
|
269
|
+
}
|
|
270
|
+
keys.forEach(key => localStorage.removeItem(key));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async LoginUser({
|
|
274
|
+
username,
|
|
275
|
+
password,
|
|
276
|
+
clientCredentials
|
|
277
|
+
}) {
|
|
278
|
+
let credentials = clientCredentials;
|
|
279
|
+
let authenticationState = {
|
|
280
|
+
clientCredentials: null,
|
|
281
|
+
isAuthenticated: false,
|
|
282
|
+
isAuthenticationError: false,
|
|
283
|
+
isError: false
|
|
284
|
+
};
|
|
285
|
+
let transientClient = null;
|
|
286
|
+
let user;
|
|
287
|
+
if (username && password) {
|
|
288
|
+
// Get a management client with username and password
|
|
289
|
+
transientClient = await getManagementApiClient({
|
|
290
|
+
username,
|
|
291
|
+
password
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
// Ensure the client has requested a bearer token
|
|
295
|
+
const [loginError, clientBearerToken] = await to(transientClient.ensureBearerToken());
|
|
296
|
+
|
|
297
|
+
// Problem getting token with username and password
|
|
298
|
+
if (loginError) {
|
|
299
|
+
authenticationState = {
|
|
300
|
+
clientCredentials: null,
|
|
301
|
+
errorMessage: loginError.message || null,
|
|
302
|
+
isAuthenticated: false,
|
|
303
|
+
isAuthenticationError: loginError.name.includes('ContensisAuthenticationError'),
|
|
304
|
+
isError: true
|
|
305
|
+
};
|
|
306
|
+
this.ClearCachedCredentials();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Got a token using username and password
|
|
310
|
+
if (clientBearerToken) {
|
|
311
|
+
// Set credentials so we can continue to GetUserDetails
|
|
312
|
+
const clientCredentials = mapClientCredentials(transientClient);
|
|
313
|
+
this.SetLoginCookies(clientCredentials);
|
|
314
|
+
authenticationState = {
|
|
315
|
+
clientCredentials,
|
|
316
|
+
isAuthenticated: true,
|
|
317
|
+
isAuthenticationError: false,
|
|
318
|
+
isError: false
|
|
319
|
+
};
|
|
320
|
+
credentials = clientCredentials;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
400
323
|
|
|
324
|
+
// If we have credentials supplied by a successful username and password login
|
|
325
|
+
// or clientCredentials supplied in the options argument we can continue to
|
|
326
|
+
// fetch the user's details
|
|
327
|
+
if (credentials) {
|
|
328
|
+
const client = transientClient || (await getManagementApiClient(credentials));
|
|
329
|
+
const [error, userDetails] = await LoginHelper.GetUserDetails(client);
|
|
330
|
+
if (error) {
|
|
331
|
+
authenticationState = {
|
|
332
|
+
clientCredentials: null,
|
|
333
|
+
errorMessage: error.message,
|
|
334
|
+
isAuthenticated: false,
|
|
335
|
+
isAuthenticationError: false,
|
|
336
|
+
isError: true
|
|
337
|
+
};
|
|
338
|
+
this.ClearCachedCredentials();
|
|
339
|
+
} else {
|
|
340
|
+
// Ensure we get latest refreshToken and contensisClassicToken from the latest client
|
|
341
|
+
const latestCredentials = mapClientCredentials(client);
|
|
342
|
+
this.SetLoginCookies(latestCredentials);
|
|
343
|
+
user = userDetails;
|
|
344
|
+
authenticationState = {
|
|
345
|
+
clientCredentials: latestCredentials,
|
|
346
|
+
isAuthenticated: true,
|
|
347
|
+
isAuthenticationError: false,
|
|
348
|
+
isError: false
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return {
|
|
353
|
+
authenticationState,
|
|
354
|
+
user
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
LogoutUser(redirectPath) {
|
|
358
|
+
this.ClearCachedCredentials();
|
|
359
|
+
if (LoginHelper.WSFED_LOGIN) {
|
|
360
|
+
LoginHelper.WsFedLogout(redirectPath);
|
|
361
|
+
} else {
|
|
362
|
+
if (redirectPath) LoginHelper.ClientRedirectToPath(redirectPath);else LoginHelper.ClientRedirectToSignInPage();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
401
365
|
}
|
|
402
|
-
|
|
403
|
-
/* global SERVERS
|
|
404
|
-
;
|
|
405
|
-
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true'
|
|
406
|
-
/* global WSFED_LOGIN */
|
|
407
|
-
: context.WSFED_LOGIN === 'true';
|
|
366
|
+
_LoginHelper = LoginHelper;
|
|
367
|
+
LoginHelper.CMS_URL = SERVERS.cms /* global SERVERS */;
|
|
368
|
+
LoginHelper.WSFED_LOGIN = process.env.NODE_ENV === 'development' ? WSFED_LOGIN === 'true' /* global WSFED_LOGIN */ : context.WSFED_LOGIN === 'true';
|
|
408
369
|
LoginHelper.LOGIN_ROUTE = '/account/login';
|
|
409
370
|
LoginHelper.ACCESS_DENIED_ROUTE = '/account/access-denied';
|
|
410
|
-
|
|
411
|
-
LoginHelper.withCookies = cookieHelper => new LoginHelper(cookieHelper);
|
|
412
|
-
|
|
371
|
+
LoginHelper.withCookies = cookieHelper => new _LoginHelper(cookieHelper);
|
|
413
372
|
LoginHelper.GetUserDetails = async client => {
|
|
414
|
-
|
|
415
|
-
groupsError,
|
|
416
|
-
user = {},
|
|
417
|
-
groupsResult;
|
|
418
|
-
[userError, user] = await to(client.security.users.getCurrent());
|
|
419
|
-
|
|
373
|
+
const [userError, user] = await to(client.security.users.getCurrent());
|
|
420
374
|
if (user && user.id) {
|
|
421
|
-
[groupsError, groupsResult] = await to(client.security.users.getUserGroups({
|
|
375
|
+
const [groupsError, groupsResult] = await to(client.security.users.getUserGroups({
|
|
422
376
|
userId: user.id,
|
|
423
377
|
includeInherited: true,
|
|
424
378
|
pageOptions: {
|
|
425
379
|
pageSize: 100
|
|
426
380
|
}
|
|
427
|
-
}));
|
|
381
|
+
}));
|
|
382
|
+
// Set groups attribute in user object to be the items
|
|
428
383
|
// array from the getUserGroups result
|
|
384
|
+
if (groupsResult && groupsResult.items) user.groups = groupsResult.items;
|
|
429
385
|
|
|
430
|
-
|
|
431
|
-
// eslint-disable-next-line no-console
|
|
386
|
+
// If groups call fails then log the error but allow the user to login still
|
|
432
387
|
|
|
433
388
|
if (groupsError) console.log(groupsError);
|
|
434
389
|
}
|
|
435
|
-
|
|
436
390
|
return [userError, user];
|
|
437
391
|
};
|
|
438
392
|
|
|
439
393
|
const loginSagas = [takeEvery(LOGIN_USER, loginUserSaga), takeEvery(LOGOUT_USER, logoutUserSaga), takeEvery(VALIDATE_USER, validateUserSaga), takeEvery(SET_AUTHENTICATION_STATE, redirectAfterSuccessfulLoginSaga)];
|
|
440
394
|
function* handleRequiresLoginSaga(action) {
|
|
441
395
|
var _entry$sys;
|
|
442
|
-
|
|
443
396
|
const {
|
|
444
397
|
cookies,
|
|
445
398
|
entry,
|
|
@@ -450,41 +403,43 @@ function* handleRequiresLoginSaga(action) {
|
|
|
450
403
|
},
|
|
451
404
|
staticRoute
|
|
452
405
|
} = action;
|
|
453
|
-
let userLoggedIn = yield select(selectUserIsAuthenticated);
|
|
406
|
+
let userLoggedIn = yield select(selectUserIsAuthenticated);
|
|
454
407
|
|
|
408
|
+
// Check for a securityToken in querystring
|
|
455
409
|
const currentQs = queryParams(yield select(selectCurrentSearch));
|
|
456
|
-
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
410
|
+
const securityToken = currentQs.securityToken || currentQs.securitytoken;
|
|
457
411
|
|
|
412
|
+
// Check if any of the defined routes have "requireLogin" attribute
|
|
458
413
|
const {
|
|
459
414
|
requireLogin: authRoute
|
|
460
415
|
} = staticRoute && staticRoute.route || {};
|
|
461
416
|
const {
|
|
462
417
|
requireLogin: authContentType
|
|
463
|
-
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0
|
|
464
|
-
// array of groups we can merge all the arrays and match on any group supplied
|
|
418
|
+
} = entry && findContentTypeMapping(ContentTypeMappings, entry === null || entry === void 0 || (_entry$sys = entry.sys) === null || _entry$sys === void 0 ? void 0 : _entry$sys.contentTypeId) || {};
|
|
465
419
|
|
|
420
|
+
// If requireLogin, authRoute or authContentType has been specified as an
|
|
421
|
+
// array of groups we can merge all the arrays and match on any group supplied
|
|
466
422
|
const routeRequiresGroups = [...(Array.isArray(authContentType) && authContentType || []), ...(Array.isArray(authRoute) && authRoute || []), ...(Array.isArray(requireLogin) && requireLogin || [])];
|
|
467
423
|
const routeRequiresLogin = !!authContentType || !!authRoute || !!requireLogin;
|
|
468
|
-
|
|
469
424
|
if (!userLoggedIn) {
|
|
470
425
|
// If cookies or securityToken are found on any route change
|
|
471
426
|
// always validate and login the user
|
|
472
427
|
if (routeRequiresLogin) {
|
|
473
|
-
console.info(`Route requires login: ${path}`);
|
|
474
|
-
|
|
428
|
+
console.info(`Route requires login: ${path}`);
|
|
429
|
+
// If routeRequiresLogin do a blocking call that returns userLoggedIn
|
|
475
430
|
userLoggedIn = yield call(validateUserSaga, {
|
|
476
431
|
cookies,
|
|
477
432
|
securityToken
|
|
478
433
|
});
|
|
479
434
|
console.info(`User logged in: ${userLoggedIn}`);
|
|
480
|
-
}
|
|
435
|
+
}
|
|
436
|
+
// otherwise do a non blocking put to handle validation in the background
|
|
481
437
|
else yield put({
|
|
482
438
|
type: VALIDATE_USER,
|
|
483
439
|
cookies,
|
|
484
440
|
securityToken
|
|
485
441
|
});
|
|
486
442
|
}
|
|
487
|
-
|
|
488
443
|
if (routeRequiresLogin) {
|
|
489
444
|
// If a security token is in the querystring and we are not already
|
|
490
445
|
// logged in something is wrong and we won't bother going on another redirect loop
|
|
@@ -496,18 +451,15 @@ function* handleRequiresLoginSaga(action) {
|
|
|
496
451
|
if (!groupMatch) LoginHelper.ClientRedirectToAccessDeniedPage(action.location.pathname);
|
|
497
452
|
}
|
|
498
453
|
}
|
|
499
|
-
|
|
500
454
|
return userLoggedIn;
|
|
501
455
|
}
|
|
502
|
-
|
|
503
456
|
function* validateUserSaga({
|
|
504
457
|
cookies,
|
|
505
458
|
securityToken
|
|
506
459
|
}) {
|
|
507
|
-
const login = LoginHelper.withCookies(cookies);
|
|
508
|
-
|
|
460
|
+
const login = LoginHelper.withCookies(cookies);
|
|
461
|
+
// Check for refreshToken in cookies
|
|
509
462
|
let clientCredentials = login.GetCachedCredentials();
|
|
510
|
-
|
|
511
463
|
if (securityToken || clientCredentials.securityToken || clientCredentials.refreshToken) {
|
|
512
464
|
// We only attempt to validate the user if one of the stored
|
|
513
465
|
// tokens are found, in this case we set loading state manually
|
|
@@ -517,12 +469,11 @@ function* validateUserSaga({
|
|
|
517
469
|
authenticationState: {
|
|
518
470
|
isLoading: true
|
|
519
471
|
}
|
|
520
|
-
});
|
|
472
|
+
});
|
|
473
|
+
// If we have just a security token we will call a CMS endpoint
|
|
521
474
|
// and provide us with a RefreshToken cookie we can use during login
|
|
522
|
-
|
|
523
475
|
if (securityToken || clientCredentials.securityToken && !clientCredentials.refreshToken) {
|
|
524
476
|
const [error, refreshToken] = yield LoginHelper.GetCredentialsForSecurityToken(securityToken || clientCredentials.securityToken);
|
|
525
|
-
|
|
526
477
|
if (refreshToken) {
|
|
527
478
|
// Set cookies and reload values
|
|
528
479
|
login.SetLoginCookies({
|
|
@@ -531,7 +482,6 @@ function* validateUserSaga({
|
|
|
531
482
|
});
|
|
532
483
|
clientCredentials = login.GetCachedCredentials();
|
|
533
484
|
}
|
|
534
|
-
|
|
535
485
|
if (error) {
|
|
536
486
|
login.ClearCachedCredentials();
|
|
537
487
|
yield put({
|
|
@@ -542,9 +492,9 @@ function* validateUserSaga({
|
|
|
542
492
|
}
|
|
543
493
|
});
|
|
544
494
|
}
|
|
545
|
-
}
|
|
546
|
-
|
|
495
|
+
}
|
|
547
496
|
|
|
497
|
+
// Log the user in if a refreshToken is found
|
|
548
498
|
if (clientCredentials.refreshToken) {
|
|
549
499
|
console.info(`Login user with refreshToken ${clientCredentials.refreshToken}`);
|
|
550
500
|
yield call(loginUserSaga, {
|
|
@@ -552,12 +502,11 @@ function* validateUserSaga({
|
|
|
552
502
|
cookies: login.cookies
|
|
553
503
|
});
|
|
554
504
|
}
|
|
555
|
-
}
|
|
556
|
-
|
|
505
|
+
}
|
|
557
506
|
|
|
507
|
+
// Tell any callers have we successfully logged in?
|
|
558
508
|
return yield select(selectUserIsAuthenticated);
|
|
559
509
|
}
|
|
560
|
-
|
|
561
510
|
function* loginUserSaga(action = {}) {
|
|
562
511
|
const {
|
|
563
512
|
username,
|
|
@@ -565,9 +514,10 @@ function* loginUserSaga(action = {}) {
|
|
|
565
514
|
clientCredentials,
|
|
566
515
|
cookies
|
|
567
516
|
} = action;
|
|
568
|
-
const login = LoginHelper.withCookies(cookies);
|
|
569
|
-
// just redirect them to the Identity Provider sign in
|
|
517
|
+
const login = LoginHelper.withCookies(cookies);
|
|
570
518
|
|
|
519
|
+
// If a WSFED_LOGIN site has dispatched the loginUser action
|
|
520
|
+
// just redirect them to the Identity Provider sign in
|
|
571
521
|
if (action.type === LOGIN_USER && LoginHelper.WSFED_LOGIN) LoginHelper.ClientRedirectToSignInPage();
|
|
572
522
|
const {
|
|
573
523
|
authenticationState,
|
|
@@ -583,33 +533,30 @@ function* loginUserSaga(action = {}) {
|
|
|
583
533
|
user
|
|
584
534
|
});
|
|
585
535
|
}
|
|
586
|
-
|
|
587
536
|
const removeHostnamePart = path => {
|
|
588
537
|
// eslint-disable-next-line no-console
|
|
589
538
|
console.log(path);
|
|
590
|
-
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
591
|
-
|
|
539
|
+
const relativePath = '/' + path.split('/').splice(3).join('/');
|
|
540
|
+
// eslint-disable-next-line no-console
|
|
592
541
|
console.log(relativePath);
|
|
593
542
|
return relativePath;
|
|
594
543
|
};
|
|
595
|
-
|
|
596
544
|
function* redirectAfterSuccessfulLoginSaga() {
|
|
597
545
|
const isLoggedIn = yield select(selectUserIsAuthenticated);
|
|
598
546
|
const {
|
|
599
547
|
redirect_uri: redirectPath,
|
|
600
548
|
ReturnURL: assetRedirectPath
|
|
601
549
|
} = queryParams(yield select(selectCurrentSearch));
|
|
602
|
-
|
|
603
550
|
if (isLoggedIn && assetRedirectPath && typeof window != 'undefined') {
|
|
604
|
-
const path = removeHostnamePart(assetRedirectPath);
|
|
551
|
+
const path = removeHostnamePart(assetRedirectPath);
|
|
552
|
+
// This has to be a hard href to get the app to
|
|
605
553
|
// leave React and hit the server for the IIS hosted assets
|
|
606
|
-
|
|
607
|
-
|
|
554
|
+
window.location.href = path;
|
|
555
|
+
// yield put(setRoute(path)); // does not work in this scenario
|
|
608
556
|
} else if (isLoggedIn && redirectPath) {
|
|
609
557
|
yield put(setRoute(redirectPath));
|
|
610
558
|
}
|
|
611
559
|
}
|
|
612
|
-
|
|
613
560
|
function* logoutUserSaga({
|
|
614
561
|
redirectPath,
|
|
615
562
|
cookies
|
|
@@ -620,10 +567,8 @@ function* logoutUserSaga({
|
|
|
620
567
|
});
|
|
621
568
|
yield LoginHelper.withCookies(cookies).LogoutUser(redirectPath);
|
|
622
569
|
}
|
|
623
|
-
|
|
624
570
|
function* refreshSecurityToken() {
|
|
625
571
|
const clientCredentials = yield select(selectClientCredentials, 'js');
|
|
626
|
-
|
|
627
572
|
if (Object.keys(clientCredentials).length > 0) {
|
|
628
573
|
const client = yield getManagementApiClient(clientCredentials);
|
|
629
574
|
yield client.authenticate();
|
|
@@ -663,12 +608,12 @@ const changePassword = (userId, currentPassword, newPassword) => action(CHANGE_U
|
|
|
663
608
|
|
|
664
609
|
var actions = /*#__PURE__*/Object.freeze({
|
|
665
610
|
__proto__: null,
|
|
611
|
+
changePassword: changePassword,
|
|
666
612
|
loginUser: loginUser,
|
|
667
613
|
logoutUser: logoutUser,
|
|
668
614
|
registerUser: registerUser,
|
|
669
615
|
requestPasswordReset: requestPasswordReset,
|
|
670
|
-
resetPassword: resetPassword
|
|
671
|
-
changePassword: changePassword
|
|
616
|
+
resetPassword: resetPassword
|
|
672
617
|
});
|
|
673
618
|
|
|
674
619
|
const useLogin = () => {
|
|
@@ -700,7 +645,6 @@ const LoginContainer = ({
|
|
|
700
645
|
const userProps = useLogin();
|
|
701
646
|
return children(userProps);
|
|
702
647
|
};
|
|
703
|
-
|
|
704
648
|
LoginContainer.propTypes = {};
|
|
705
649
|
var Login_container = toJS(LoginContainer);
|
|
706
650
|
|
|
@@ -723,7 +667,6 @@ const RegistrationContainer = ({
|
|
|
723
667
|
const userProps = useRegistration();
|
|
724
668
|
return children(userProps);
|
|
725
669
|
};
|
|
726
|
-
|
|
727
670
|
RegistrationContainer.propTypes = {};
|
|
728
671
|
var Registration_container = toJS(RegistrationContainer);
|
|
729
672
|
|
|
@@ -752,7 +695,6 @@ const ForgotPasswordContainer = ({
|
|
|
752
695
|
const userProps = useForgotPassword();
|
|
753
696
|
return children(userProps);
|
|
754
697
|
};
|
|
755
|
-
|
|
756
698
|
ForgotPasswordContainer.propTypes = {};
|
|
757
699
|
var ForgotPassword_container = toJS(ForgotPasswordContainer);
|
|
758
700
|
|
|
@@ -776,9 +718,8 @@ const ChangePasswordContainer = ({
|
|
|
776
718
|
const userProps = useChangePassword();
|
|
777
719
|
return children(userProps);
|
|
778
720
|
};
|
|
779
|
-
|
|
780
721
|
ChangePasswordContainer.propTypes = {};
|
|
781
722
|
var ChangePassword_container = toJS(ChangePasswordContainer);
|
|
782
723
|
|
|
783
|
-
export { ChangePassword_container as C, ForgotPassword_container as F, LoginHelper as L, Registration_container as R, loginUser as a,
|
|
784
|
-
//# sourceMappingURL=ChangePassword.container-
|
|
724
|
+
export { ChangePassword_container as C, ForgotPassword_container as F, LoginHelper as L, Registration_container as R, loginUser as a, actions as b, Login_container as c, useRegistration as d, useForgotPassword as e, useChangePassword as f, refreshSecurityToken as g, handleRequiresLoginSaga as h, findContentTypeMapping as i, getManagementApiClient as j, loginSagas as k, logoutUser as l, registerUser as r, useLogin as u };
|
|
725
|
+
//# sourceMappingURL=ChangePassword.container-Q7bElOVz.js.map
|