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