@beinformed/ui 1.18.3 → 1.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/esm/constants/Constants.js +1 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +10 -3
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useAuthentication.js +7 -50
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/i18n/Locales.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/form/FormModel.js +3 -1
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/tab/TabModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +100 -21
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/redux/actions/Preferences.js +2 -2
- package/esm/redux/actions/Preferences.js.map +1 -1
- package/esm/redux/actions/SignOut.js +6 -2
- package/esm/redux/actions/SignOut.js.map +1 -1
- package/esm/redux/connectors/SignIn.js +3 -2
- package/esm/redux/connectors/SignIn.js.map +1 -1
- package/esm/redux/connectors/SignOut.js +4 -1
- package/esm/redux/connectors/SignOut.js.map +1 -1
- package/esm/redux/reducers/AuthReducer.js +0 -10
- package/esm/redux/reducers/AuthReducer.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/esm/utils/helpers/checkResource.js +2 -0
- package/esm/utils/helpers/checkResource.js.map +1 -1
- package/lib/constants/Constants.js +3 -1
- package/lib/constants/Constants.js.flow +1 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/LayoutHints.js.map +1 -1
- package/lib/constants/Settings.js +13 -3
- package/lib/constants/Settings.js.flow +8 -3
- package/lib/constants/Settings.js.map +1 -1
- package/lib/exceptions/FetchException.js.map +1 -1
- package/lib/hooks/__tests__/useAuthentication.spec.js.flow +15 -1
- package/lib/hooks/useAllFormsOnModel.js.map +1 -1
- package/lib/hooks/useAuthentication.js +7 -55
- package/lib/hooks/useAuthentication.js.flow +4 -37
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/hooks/useContent.js.map +1 -1
- package/lib/hooks/useDeepCompareEffect.js.map +1 -1
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useI18n.js.map +1 -1
- package/lib/hooks/useModal.js.map +1 -1
- package/lib/hooks/useModelCatalog.js.map +1 -1
- package/lib/hooks/useModels.js.map +1 -1
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/hooks/useModularUIRequest.js.map +1 -1
- package/lib/hooks/useNotification.js.map +1 -1
- package/lib/hooks/usePreference.js.map +1 -1
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/Locales.js.map +1 -1
- package/lib/i18n/Message.js.map +1 -1
- package/lib/i18n/withMessage.js.map +1 -1
- package/lib/models/actions/ActionModel.js.map +1 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/attributes/AttributeCollection.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/BooleanAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
- package/lib/models/attributes/CompositeAttributeModel.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/MemoAttributeModel.js.map +1 -1
- package/lib/models/attributes/MoneyAttributeModel.js.map +1 -1
- package/lib/models/attributes/NumberAttributeModel.js.map +1 -1
- package/lib/models/attributes/StringAttributeModel.js.map +1 -1
- package/lib/models/attributes/XMLAttributeModel.js.map +1 -1
- package/lib/models/attributes/_createAttribute.js.map +1 -1
- package/lib/models/attributes/input-constraints/ConstraintCollection.js.map +1 -1
- package/lib/models/attributes/input-constraints/ConstraintModel.js.map +1 -1
- package/lib/models/attributes/input-constraints/DateTimeDateFormatConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/DateTimeTimeFormatConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/FileSizeConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/IBANConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/NumberBoundaryConstraint.js.map +1 -1
- package/lib/models/attributes/input-constraints/NumberFormatConstraint.js.map +1 -1
- package/lib/models/base/BaseCollection.js.map +1 -1
- package/lib/models/base/BaseModel.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/filters/BaseFilterModel.js.map +1 -1
- package/lib/models/form/FormModel.js +3 -1
- package/lib/models/form/FormModel.js.flow +1 -1
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListHeaderModel.js.map +1 -1
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/lookup/LookupOptionsModel.js.map +1 -1
- package/lib/models/paging/PagingModel.js.map +1 -1
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/parameter/Parameter.js.map +1 -1
- package/lib/models/process/ProcessStatusSettingsModel.js.map +1 -1
- package/lib/models/resolveModel.js.map +1 -1
- package/lib/models/sorting/SortingModel.js.map +1 -1
- package/lib/models/tab/TabModel.js.map +1 -1
- package/lib/models/user/UserProfileModel.js.map +1 -1
- package/lib/models/user/UserServicesModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +102 -21
- package/lib/modularui/Authenticate.js.flow +75 -20
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/ModularUIResponse.js.map +1 -1
- package/lib/react/ErrorBoundaryFallback.js.map +1 -1
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-client/rehydrate.js.map +1 -1
- package/lib/react-server/__tests__/serverUtil.spec.js.flow +6 -4
- package/lib/react-server/createSSRComplete.js.map +1 -1
- package/lib/react-server/renderSSRComplete.js.map +1 -1
- package/lib/react-server/renderSSRMinimal.js.map +1 -1
- package/lib/react-server/serverNoSSR.js.map +1 -1
- package/lib/react-server/serverSSR.js.map +1 -1
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/react-theme/ThemeProvider.js.map +1 -1
- package/lib/react-theme/createTheme.js.map +1 -1
- package/lib/react-theme/useTheme.js.map +1 -1
- package/lib/react-theme/utils/background.js.map +1 -1
- package/lib/react-theme/utils/colors.js.map +1 -1
- package/lib/react-theme/utils/contrast.js.map +1 -1
- package/lib/react-theme/utils/corners.js.map +1 -1
- package/lib/react-theme/utils/spacers.js.map +1 -1
- package/lib/react-theme/utils/themeProps.js.map +1 -1
- package/lib/redux/_i18n/actions.js.map +1 -1
- package/lib/redux/_i18n/reducer.js.map +1 -1
- package/lib/redux/_modularui/actions.js.map +1 -1
- package/lib/redux/_modularui/connector.js.map +1 -1
- package/lib/redux/_modularui/middleware.js.map +1 -1
- package/lib/redux/_modularui/modularuiUtils.js.map +1 -1
- package/lib/redux/_modularui/reducer.js.map +1 -1
- package/lib/redux/_modularui/selectors.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/redux/_router/connectors.js.map +1 -1
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/actions/Authorization.js.map +1 -1
- package/lib/redux/actions/Error.js.map +1 -1
- package/lib/redux/actions/Form.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormAutosubmit.js.map +1 -1
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/lib/redux/actions/Notification.js.map +1 -1
- package/lib/redux/actions/Preferences.js +1 -1
- package/lib/redux/actions/Preferences.js.flow +7 -3
- package/lib/redux/actions/Preferences.js.map +1 -1
- package/lib/redux/actions/SignIn.js.map +1 -1
- package/lib/redux/actions/SignOut.js +6 -1
- package/lib/redux/actions/SignOut.js.flow +9 -5
- package/lib/redux/actions/SignOut.js.map +1 -1
- package/lib/redux/connectors/Application.js.map +1 -1
- package/lib/redux/connectors/Breadcrumb.js.map +1 -1
- package/lib/redux/connectors/CaseView.js.map +1 -1
- package/lib/redux/connectors/ConceptDetail.js.map +1 -1
- package/lib/redux/connectors/ContentBrowser.js.map +1 -1
- package/lib/redux/connectors/ContentDetail.js.map +1 -1
- package/lib/redux/connectors/ContentDetailSection.js.map +1 -1
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/connectors/ListDetail.js.map +1 -1
- package/lib/redux/connectors/Modal.js.map +1 -1
- package/lib/redux/connectors/ModelCatalog.js.map +1 -1
- package/lib/redux/connectors/Notification.js.map +1 -1
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/redux/connectors/Preferences.js.map +1 -1
- package/lib/redux/connectors/Progress.js.map +1 -1
- package/lib/redux/connectors/ProgressIndicator.js.map +1 -1
- package/lib/redux/connectors/QuickSearch.js.map +1 -1
- package/lib/redux/connectors/SignIn.js +3 -5
- package/lib/redux/connectors/SignIn.js.flow +1 -6
- package/lib/redux/connectors/SignIn.js.map +1 -1
- package/lib/redux/connectors/SignOut.js +5 -1
- package/lib/redux/connectors/SignOut.js.flow +2 -1
- package/lib/redux/connectors/SignOut.js.map +1 -1
- package/lib/redux/connectors/Tab.js.map +1 -1
- package/lib/redux/reducers/AuthReducer.js +0 -11
- package/lib/redux/reducers/AuthReducer.js.flow +0 -11
- package/lib/redux/reducers/AuthReducer.js.map +1 -1
- package/lib/redux/reducers/__tests__/AuthReducer.spec.js.flow +0 -9
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.flow +0 -1
- package/lib/redux/types.js.map +1 -1
- package/lib/utils/browser/Cookies.js.map +1 -1
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/utils/fetch/universalFetch.js.map +1 -1
- package/lib/utils/fetch/xhr.js.map +1 -1
- package/lib/utils/helpers/checkResource.js +2 -0
- package/lib/utils/helpers/checkResource.js.flow +3 -0
- package/lib/utils/helpers/checkResource.js.map +1 -1
- package/lib/utils/helpers/objects.js.map +1 -1
- package/lib/utils/helpers/sanitizeHtml.js.map +1 -1
- package/lib/utils/helpers/text.js.map +1 -1
- package/lib/utils/number/formatValue.js.map +1 -1
- package/lib/utils/number/parseNumbers.js.map +1 -1
- package/package.json +22 -22
- package/src/constants/Constants.js +1 -0
- package/src/constants/Settings.js +8 -3
- package/src/hooks/__tests__/useAuthentication.spec.js +15 -1
- package/src/hooks/useAuthentication.js +4 -37
- package/src/models/form/FormModel.js +1 -1
- package/src/modularui/Authenticate.js +75 -20
- package/src/react-server/__tests__/serverUtil.spec.js +6 -4
- package/src/redux/actions/Preferences.js +7 -3
- package/src/redux/actions/SignOut.js +9 -5
- package/src/redux/connectors/SignIn.js +1 -6
- package/src/redux/connectors/SignOut.js +2 -1
- package/src/redux/reducers/AuthReducer.js +0 -11
- package/src/redux/reducers/__tests__/AuthReducer.spec.js +0 -9
- package/src/redux/types.js +0 -1
- package/src/utils/helpers/checkResource.js +3 -0
|
@@ -5,10 +5,10 @@ import universalFetch from "../utils/fetch/universalFetch";
|
|
|
5
5
|
import Cache from "../utils/browser/Cache";
|
|
6
6
|
|
|
7
7
|
import { UnauthorizedException } from "../exceptions";
|
|
8
|
-
import type { RequestOptions } from "../utils/fetch/types";
|
|
9
8
|
import {
|
|
10
|
-
|
|
9
|
+
loginType,
|
|
11
10
|
loginPath,
|
|
11
|
+
loginPasswordField,
|
|
12
12
|
loginUsernameField,
|
|
13
13
|
logoutPath,
|
|
14
14
|
} from "../constants";
|
|
@@ -24,10 +24,27 @@ class Authenticate {
|
|
|
24
24
|
this._isBasic = false;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
*/
|
|
29
|
+
get authenticationType(): "JAAS" | "PAC4J_FORM" | "PAC4J_BASIC" {
|
|
30
|
+
const type = loginType();
|
|
31
|
+
|
|
32
|
+
if (!type || type === "JAAS") {
|
|
33
|
+
return "JAAS";
|
|
34
|
+
}
|
|
35
|
+
if (type.includes("FormClient")) {
|
|
36
|
+
return "PAC4J_FORM";
|
|
37
|
+
} else if (type.includes("BasicClient")) {
|
|
38
|
+
return "PAC4J_BASIC";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
throw new Error(`Unsupported login type found: ${type}`);
|
|
42
|
+
}
|
|
43
|
+
|
|
27
44
|
/**
|
|
28
45
|
*/
|
|
29
46
|
get isBasicAuthentication(): boolean {
|
|
30
|
-
return this._isBasic;
|
|
47
|
+
return this._isBasic || this.authenticationType === "PAC4J_BASIC";
|
|
31
48
|
}
|
|
32
49
|
|
|
33
50
|
/**
|
|
@@ -64,47 +81,85 @@ class Authenticate {
|
|
|
64
81
|
|
|
65
82
|
/**
|
|
66
83
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
84
|
+
login(username: string, password: string): Promise<any> {
|
|
85
|
+
switch (this.authenticationType) {
|
|
86
|
+
case "PAC4J_FORM":
|
|
87
|
+
return this.doFormLogin(username, password);
|
|
88
|
+
case "PAC4J_BASIC":
|
|
89
|
+
return this.doBasicAuthentication(username, password);
|
|
90
|
+
default:
|
|
91
|
+
return this.doJaasAuthentication(username, password);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*/
|
|
97
|
+
getFormLoginUrl(): string {
|
|
98
|
+
switch (this.authenticationType) {
|
|
99
|
+
case "PAC4J_BASIC":
|
|
100
|
+
case "PAC4J_FORM":
|
|
101
|
+
return `${BASE}${loginPath()}`;
|
|
102
|
+
default:
|
|
103
|
+
return `${BASE}/j_security_check`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
71
106
|
|
|
107
|
+
/**
|
|
108
|
+
*/
|
|
109
|
+
getFormLoginData(username: string, password: string): string {
|
|
72
110
|
const encodedUsername = encodeURIComponent(username);
|
|
73
111
|
const encodedPassword = encodeURIComponent(password);
|
|
74
112
|
|
|
75
|
-
|
|
76
|
-
|
|
113
|
+
switch (this.authenticationType) {
|
|
114
|
+
case "PAC4J_BASIC":
|
|
115
|
+
case "PAC4J_FORM":
|
|
116
|
+
return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;
|
|
117
|
+
default:
|
|
118
|
+
return `j_username=${encodedUsername}&j_password=${encodedPassword}`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
*/
|
|
124
|
+
doFormLogin(username: string, password: string): Promise<any> {
|
|
125
|
+
return universalFetch({
|
|
126
|
+
url: this.getFormLoginUrl(),
|
|
77
127
|
method: HTTP_METHODS.POST,
|
|
78
128
|
headers: {
|
|
79
129
|
Accept: "application/json",
|
|
80
130
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
81
131
|
},
|
|
82
|
-
data:
|
|
83
|
-
};
|
|
132
|
+
data: this.getFormLoginData(username, password),
|
|
133
|
+
});
|
|
84
134
|
}
|
|
85
135
|
|
|
86
136
|
/**
|
|
87
137
|
*/
|
|
88
|
-
|
|
138
|
+
doBasicAuthentication(username: string, password: string): Promise<any> {
|
|
139
|
+
Cache.addItem("basic", btoa(`${username}:${password}`));
|
|
140
|
+
return Promise.resolve();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*/
|
|
145
|
+
doJaasAuthentication(username: string, password: string): Promise<any> {
|
|
89
146
|
return this.initLogin(true).then(() => {
|
|
90
147
|
if (this.isBasicAuthentication) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return Promise.resolve();
|
|
148
|
+
return this.doBasicAuthentication(username, password);
|
|
94
149
|
}
|
|
95
|
-
|
|
96
|
-
return universalFetch(this.createLogin(username, password));
|
|
150
|
+
return this.doFormLogin(username, password);
|
|
97
151
|
});
|
|
98
152
|
}
|
|
99
153
|
|
|
100
154
|
/**
|
|
101
155
|
*/
|
|
102
|
-
logout(): Promise<
|
|
156
|
+
logout(): Promise<any> {
|
|
103
157
|
return universalFetch({
|
|
104
|
-
url: logoutPath()
|
|
105
|
-
}).then(() => {
|
|
158
|
+
url: `${BASE}${logoutPath()}`,
|
|
159
|
+
}).then((response) => {
|
|
106
160
|
// clear cache because of cached contributions
|
|
107
161
|
Cache.clear();
|
|
162
|
+
return response;
|
|
108
163
|
});
|
|
109
164
|
}
|
|
110
165
|
}
|
|
@@ -112,10 +112,11 @@ describe("serverUtil", () => {
|
|
|
112
112
|
{
|
|
113
113
|
type: "SET_PREFERENCES",
|
|
114
114
|
payload: {
|
|
115
|
-
"FormClient.login_url": "/
|
|
116
|
-
"FormClient.logout_url": "/
|
|
115
|
+
"FormClient.login_url": "/j_security_check",
|
|
116
|
+
"FormClient.logout_url": "/Logoff",
|
|
117
117
|
"FormClient.password_field_name": "j_password",
|
|
118
118
|
"FormClient.username_field_name": "j_username",
|
|
119
|
+
"security.clients": null,
|
|
119
120
|
},
|
|
120
121
|
},
|
|
121
122
|
]);
|
|
@@ -158,10 +159,11 @@ describe("serverUtil", () => {
|
|
|
158
159
|
{
|
|
159
160
|
type: "SET_PREFERENCES",
|
|
160
161
|
payload: {
|
|
161
|
-
"FormClient.login_url": "/
|
|
162
|
-
"FormClient.logout_url": "/
|
|
162
|
+
"FormClient.login_url": "/j_security_check",
|
|
163
|
+
"FormClient.logout_url": "/Logoff",
|
|
163
164
|
"FormClient.password_field_name": "j_password",
|
|
164
165
|
"FormClient.username_field_name": "j_username",
|
|
166
|
+
"security.clients": null,
|
|
165
167
|
},
|
|
166
168
|
},
|
|
167
169
|
]);
|
|
@@ -12,8 +12,8 @@ import type {
|
|
|
12
12
|
} from "../types";
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
|
-
BASE,
|
|
16
15
|
ALL_CONTENT_IN_DATA_SETTING,
|
|
16
|
+
LOGIN_TYPE,
|
|
17
17
|
LOGIN_PASSWORD_SETTING,
|
|
18
18
|
LOGIN_PATH_SETTING,
|
|
19
19
|
LOGIN_USERNAME_SETTING,
|
|
@@ -123,9 +123,13 @@ export const setLoginPreferences = (
|
|
|
123
123
|
state?: ReduxState
|
|
124
124
|
): SetPreferencesAction => {
|
|
125
125
|
const loginSettings = {
|
|
126
|
+
[LOGIN_TYPE]: getServerPreferenceValue(
|
|
127
|
+
LOGIN_TYPE,
|
|
128
|
+
state?.preferences[LOGIN_TYPE]
|
|
129
|
+
),
|
|
126
130
|
[LOGIN_PATH_SETTING]: getServerPreferenceValue(
|
|
127
131
|
LOGIN_PATH_SETTING,
|
|
128
|
-
state?.preferences[LOGIN_PATH_SETTING] ??
|
|
132
|
+
state?.preferences[LOGIN_PATH_SETTING] ?? `/j_security_check`
|
|
129
133
|
),
|
|
130
134
|
[LOGIN_USERNAME_SETTING]: getServerPreferenceValue(
|
|
131
135
|
LOGIN_USERNAME_SETTING,
|
|
@@ -137,7 +141,7 @@ export const setLoginPreferences = (
|
|
|
137
141
|
),
|
|
138
142
|
[LOGOUT_PATH_SETTING]: getServerPreferenceValue(
|
|
139
143
|
LOGOUT_PATH_SETTING,
|
|
140
|
-
state?.preferences[LOGOUT_PATH_SETTING] ??
|
|
144
|
+
state?.preferences[LOGOUT_PATH_SETTING] ?? `/Logoff`
|
|
141
145
|
),
|
|
142
146
|
};
|
|
143
147
|
|
|
@@ -4,6 +4,7 @@ import { startProgress, finishProgress } from "./ProgressIndicator";
|
|
|
4
4
|
import { resetModularUI } from "../_modularui/actions";
|
|
5
5
|
|
|
6
6
|
import type { Dispatch, LogoutSuccessAction, ThunkAction } from "../types";
|
|
7
|
+
import { reloadApplication } from "./Application";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Send logout success action
|
|
@@ -17,9 +18,12 @@ export const logoutSuccess = (): LogoutSuccessAction => ({
|
|
|
17
18
|
export const logout = (): ThunkAction => (dispatch: Dispatch) => {
|
|
18
19
|
dispatch(startProgress());
|
|
19
20
|
|
|
20
|
-
return new Authenticate()
|
|
21
|
-
|
|
22
|
-
dispatch(
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
return new Authenticate()
|
|
22
|
+
.logout()
|
|
23
|
+
.then(() => dispatch(resetModularUI()))
|
|
24
|
+
.then(() => dispatch(reloadApplication()))
|
|
25
|
+
.then(() => {
|
|
26
|
+
dispatch(logoutSuccess());
|
|
27
|
+
return dispatch(finishProgress());
|
|
28
|
+
});
|
|
25
29
|
};
|
|
@@ -5,8 +5,6 @@ import { login } from "../actions/SignIn";
|
|
|
5
5
|
|
|
6
6
|
import { getApplication } from "../_modularui/selectors";
|
|
7
7
|
|
|
8
|
-
import UserServicesModel from "../../models/user/UserServicesModel";
|
|
9
|
-
|
|
10
8
|
import type { ReduxState, ThunkAction } from "../types";
|
|
11
9
|
import type { ComponentType } from "react";
|
|
12
10
|
|
|
@@ -28,10 +26,7 @@ const mapStateToProps = (state: ReduxState): StateProps => {
|
|
|
28
26
|
const application = getApplication(state);
|
|
29
27
|
|
|
30
28
|
return {
|
|
31
|
-
isAuthenticated:
|
|
32
|
-
state.auth.isAuthenticated &&
|
|
33
|
-
application?.userServices instanceof UserServicesModel &&
|
|
34
|
-
application.userServices.isLoggedIn,
|
|
29
|
+
isAuthenticated: application?.isLoggedIn ?? false,
|
|
35
30
|
errorMessage: state.auth.error,
|
|
36
31
|
};
|
|
37
32
|
};
|
|
@@ -5,6 +5,7 @@ import { logout } from "../actions/SignOut";
|
|
|
5
5
|
|
|
6
6
|
import type { ThunkAction } from "../types";
|
|
7
7
|
import type { ComponentType } from "react";
|
|
8
|
+
import { getApplication } from "../_modularui";
|
|
8
9
|
|
|
9
10
|
type StateProps = {
|
|
10
11
|
isAuthenticated: boolean,
|
|
@@ -20,7 +21,7 @@ type Props = {
|
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const mapStateToProps = (state): StateProps => ({
|
|
23
|
-
isAuthenticated: state
|
|
24
|
+
isAuthenticated: getApplication(state)?.isLoggedIn ?? false,
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
const mapDispatchToProps = { doLogout: logout };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import Cache from "../../utils/browser/Cache";
|
|
3
|
-
|
|
4
2
|
import type { Reducer } from "redux";
|
|
5
3
|
import type { AuthState, ReduxAction } from "../types";
|
|
6
4
|
|
|
7
5
|
// REDUCER
|
|
8
6
|
const initialState: AuthState = {
|
|
9
|
-
isAuthenticated: false,
|
|
10
7
|
mustChangePassword: false,
|
|
11
8
|
error: null,
|
|
12
9
|
};
|
|
@@ -26,7 +23,6 @@ const AuthReducer: Reducer<AuthState, ReduxAction> = (
|
|
|
26
23
|
case "AUTHENTICATION_SUCCESS":
|
|
27
24
|
return {
|
|
28
25
|
...state,
|
|
29
|
-
isAuthenticated: true,
|
|
30
26
|
error: null,
|
|
31
27
|
mustChangePassword: false,
|
|
32
28
|
};
|
|
@@ -38,15 +34,9 @@ const AuthReducer: Reducer<AuthState, ReduxAction> = (
|
|
|
38
34
|
return { ...state, error: null };
|
|
39
35
|
|
|
40
36
|
case "AUTHENTICATION_LOGOUT": {
|
|
41
|
-
// clear cache because of cached contributions
|
|
42
|
-
if (state.isAuthenticated) {
|
|
43
|
-
Cache.clear();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
37
|
return {
|
|
47
38
|
...state,
|
|
48
39
|
mustChangePassword: false,
|
|
49
|
-
isAuthenticated: false,
|
|
50
40
|
error: null,
|
|
51
41
|
};
|
|
52
42
|
}
|
|
@@ -54,7 +44,6 @@ const AuthReducer: Reducer<AuthState, ReduxAction> = (
|
|
|
54
44
|
case "CHANGE_PASSWORD":
|
|
55
45
|
return {
|
|
56
46
|
...state,
|
|
57
|
-
isAuthenticated: true,
|
|
58
47
|
mustChangePassword: true,
|
|
59
48
|
error: null,
|
|
60
49
|
};
|
|
@@ -3,13 +3,11 @@ import AuthReducer from "../AuthReducer";
|
|
|
3
3
|
describe("authentication reducer", () => {
|
|
4
4
|
it("should return the initial state", () => {
|
|
5
5
|
expect(AuthReducer(undefined, {})).toStrictEqual({
|
|
6
|
-
isAuthenticated: false,
|
|
7
6
|
mustChangePassword: false,
|
|
8
7
|
error: null,
|
|
9
8
|
});
|
|
10
9
|
|
|
11
10
|
expect(AuthReducer()).toStrictEqual({
|
|
12
|
-
isAuthenticated: false,
|
|
13
11
|
mustChangePassword: false,
|
|
14
12
|
error: null,
|
|
15
13
|
});
|
|
@@ -24,7 +22,6 @@ describe("authentication reducer", () => {
|
|
|
24
22
|
}
|
|
25
23
|
)
|
|
26
24
|
).toStrictEqual({
|
|
27
|
-
isAuthenticated: true,
|
|
28
25
|
mustChangePassword: false,
|
|
29
26
|
error: null,
|
|
30
27
|
});
|
|
@@ -49,7 +46,6 @@ describe("authentication reducer", () => {
|
|
|
49
46
|
expect(
|
|
50
47
|
AuthReducer(
|
|
51
48
|
{
|
|
52
|
-
isAuthenticated: true,
|
|
53
49
|
mustChangePassword: false,
|
|
54
50
|
error: null,
|
|
55
51
|
},
|
|
@@ -58,7 +54,6 @@ describe("authentication reducer", () => {
|
|
|
58
54
|
}
|
|
59
55
|
)
|
|
60
56
|
).toStrictEqual({
|
|
61
|
-
isAuthenticated: false,
|
|
62
57
|
mustChangePassword: false,
|
|
63
58
|
error: null,
|
|
64
59
|
});
|
|
@@ -68,7 +63,6 @@ describe("authentication reducer", () => {
|
|
|
68
63
|
expect(
|
|
69
64
|
AuthReducer(
|
|
70
65
|
{
|
|
71
|
-
isAuthenticated: false,
|
|
72
66
|
mustChangePassword: false,
|
|
73
67
|
error: "In error",
|
|
74
68
|
},
|
|
@@ -77,7 +71,6 @@ describe("authentication reducer", () => {
|
|
|
77
71
|
}
|
|
78
72
|
)
|
|
79
73
|
).toStrictEqual({
|
|
80
|
-
isAuthenticated: false,
|
|
81
74
|
mustChangePassword: false,
|
|
82
75
|
error: null,
|
|
83
76
|
});
|
|
@@ -87,7 +80,6 @@ describe("authentication reducer", () => {
|
|
|
87
80
|
expect(
|
|
88
81
|
AuthReducer(
|
|
89
82
|
{
|
|
90
|
-
isAuthenticated: true,
|
|
91
83
|
mustChangePassword: false,
|
|
92
84
|
error: null,
|
|
93
85
|
},
|
|
@@ -96,7 +88,6 @@ describe("authentication reducer", () => {
|
|
|
96
88
|
}
|
|
97
89
|
)
|
|
98
90
|
).toStrictEqual({
|
|
99
|
-
isAuthenticated: true,
|
|
100
91
|
mustChangePassword: true,
|
|
101
92
|
error: null,
|
|
102
93
|
});
|
package/src/redux/types.js
CHANGED
|
@@ -17,6 +17,8 @@ export const resourceExists = (url: string | Href): boolean => {
|
|
|
17
17
|
xhr.open("HEAD", fullUrl, false);
|
|
18
18
|
xhr.setRequestHeader("Accept", "application/json");
|
|
19
19
|
xhr.setRequestHeader("Content-Type", "application/json");
|
|
20
|
+
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
|
21
|
+
|
|
20
22
|
xhr.send();
|
|
21
23
|
|
|
22
24
|
return xhr.status !== 404;
|
|
@@ -34,6 +36,7 @@ export const resourceRedirectsToSecureLogin = (url: string | Href): boolean => {
|
|
|
34
36
|
xhr.open("HEAD", fullUrl, false);
|
|
35
37
|
xhr.setRequestHeader("Accept", "application/json");
|
|
36
38
|
xhr.setRequestHeader("Content-Type", "application/json");
|
|
39
|
+
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
|
|
37
40
|
xhr.send();
|
|
38
41
|
|
|
39
42
|
const responseURL = xhr.responseURL ?? "";
|