@beinformed/ui 1.27.2 → 1.27.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/esm/constants/Constants.js +5 -0
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/constants/Settings.js +6 -4
  5. package/esm/constants/Settings.js.map +1 -1
  6. package/esm/models/application/ApplicationModel.js +6 -3
  7. package/esm/models/application/ApplicationModel.js.map +1 -1
  8. package/esm/modularui/Authenticate.js +25 -13
  9. package/esm/modularui/Authenticate.js.map +1 -1
  10. package/esm/react/ErrorBoundaryFallback.js +3 -0
  11. package/esm/react/ErrorBoundaryFallback.js.map +1 -1
  12. package/esm/react-server/serverUtil.js +1 -0
  13. package/esm/react-server/serverUtil.js.map +1 -1
  14. package/lib/constants/Constants.js +7 -1
  15. package/lib/constants/Constants.js.flow +5 -0
  16. package/lib/constants/Constants.js.map +1 -1
  17. package/lib/constants/Settings.js +5 -3
  18. package/lib/constants/Settings.js.flow +7 -3
  19. package/lib/constants/Settings.js.map +1 -1
  20. package/lib/models/application/ApplicationModel.js +6 -3
  21. package/lib/models/application/ApplicationModel.js.flow +10 -5
  22. package/lib/models/application/ApplicationModel.js.map +1 -1
  23. package/lib/modularui/Authenticate.js +24 -12
  24. package/lib/modularui/Authenticate.js.flow +30 -13
  25. package/lib/modularui/Authenticate.js.map +1 -1
  26. package/lib/react/ErrorBoundaryFallback.js +3 -0
  27. package/lib/react/ErrorBoundaryFallback.js.flow +2 -0
  28. package/lib/react/ErrorBoundaryFallback.js.map +1 -1
  29. package/lib/react-server/serverUtil.js +1 -0
  30. package/lib/react-server/serverUtil.js.flow +2 -0
  31. package/lib/react-server/serverUtil.js.map +1 -1
  32. package/package.json +3 -3
  33. package/src/constants/Constants.js +5 -0
  34. package/src/constants/Settings.js +7 -3
  35. package/src/models/application/ApplicationModel.js +10 -5
  36. package/src/modularui/Authenticate.js +30 -13
  37. package/src/react/ErrorBoundaryFallback.js +2 -0
  38. package/src/react-server/serverUtil.js +2 -0
  39. package/types/constants/Constants.d.ts +5 -0
  40. package/types/modularui/Authenticate.d.ts +8 -1
@@ -80,12 +80,17 @@ export default class ApplicationModel extends ResourceModel {
80
80
  DEFAULT_AUTHENTICATION_TYPE,
81
81
  ]);
82
82
 
83
- //put primary first
84
- return authenticationTypes?.sort(
85
- (a: AuthenticationType, b: AuthenticationType) =>
86
- a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1
87
- );
83
+ if (authenticationTypes) {
84
+ //put primary first
85
+ return authenticationTypes?.sort(
86
+ (a: AuthenticationType, b: AuthenticationType) =>
87
+ a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1
88
+ );
89
+ }
90
+
91
+ return [DEFAULT_AUTHENTICATION_TYPE];
88
92
  }
93
+
89
94
  /**
90
95
  * Getting the tab links
91
96
  */
@@ -6,6 +6,7 @@ import Cache from "../utils/browser/Cache";
6
6
 
7
7
  import { UnauthorizedException } from "../exceptions";
8
8
  import {
9
+ INTERNAL_LOGIN_TYPE,
9
10
  loginType,
10
11
  loginPath,
11
12
  loginPasswordField,
@@ -27,16 +28,17 @@ class Authenticate {
27
28
 
28
29
  /**
29
30
  */
30
- get authenticationType(): "JAAS" | "PAC4J_FORM" | "PAC4J_BASIC" {
31
+ get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {
31
32
  const type = loginType();
32
33
 
33
- if (!type || type === "JAAS") {
34
- return "JAAS";
34
+ if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {
35
+ return INTERNAL_LOGIN_TYPE.JAAS;
35
36
  }
37
+
36
38
  if (type.includes("FormClient")) {
37
- return "PAC4J_FORM";
39
+ return INTERNAL_LOGIN_TYPE.PAC4J_FORM;
38
40
  } else if (type.includes("BasicClient")) {
39
- return "PAC4J_BASIC";
41
+ return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;
40
42
  }
41
43
 
42
44
  throw new Error(`Unsupported login type found: ${type}`);
@@ -45,7 +47,10 @@ class Authenticate {
45
47
  /**
46
48
  */
47
49
  get isBasicAuthentication(): boolean {
48
- return this._isBasic || this.authenticationType === "PAC4J_BASIC";
50
+ return (
51
+ this._isBasic ||
52
+ this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC
53
+ );
49
54
  }
50
55
 
51
56
  /**
@@ -90,9 +95,9 @@ class Authenticate {
90
95
  */
91
96
  login(username: string, password: string): Promise<any> {
92
97
  switch (this.authenticationType) {
93
- case "PAC4J_FORM":
98
+ case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
94
99
  return this.doFormLogin(username, password);
95
- case "PAC4J_BASIC":
100
+ case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
96
101
  return this.doBasicAuthentication(username, password);
97
102
  default:
98
103
  return this.doJaasAuthentication(username, password);
@@ -103,8 +108,8 @@ class Authenticate {
103
108
  */
104
109
  getFormLoginUrl(): string {
105
110
  switch (this.authenticationType) {
106
- case "PAC4J_BASIC":
107
- case "PAC4J_FORM":
111
+ case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
112
+ case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
108
113
  return `${getBasePath()}${loginPath()}`;
109
114
  default:
110
115
  return `${getBasePath()}/j_security_check`;
@@ -118,8 +123,8 @@ class Authenticate {
118
123
  const encodedPassword = encodeURIComponent(password);
119
124
 
120
125
  switch (this.authenticationType) {
121
- case "PAC4J_BASIC":
122
- case "PAC4J_FORM":
126
+ case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
127
+ case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
123
128
  return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;
124
129
  default:
125
130
  return `j_username=${encodedUsername}&j_password=${encodedPassword}`;
@@ -158,11 +163,23 @@ class Authenticate {
158
163
  });
159
164
  }
160
165
 
166
+ /**
167
+ */
168
+ getLogoutUrl(): string {
169
+ switch (this.authenticationType) {
170
+ case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:
171
+ case INTERNAL_LOGIN_TYPE.PAC4J_FORM:
172
+ return `${getBasePath()}${logoutPath()}`;
173
+ default:
174
+ return `${getBasePath()}/Logoff`;
175
+ }
176
+ }
177
+
161
178
  /**
162
179
  */
163
180
  logout(): Promise<any> {
164
181
  return universalFetch({
165
- url: `${getBasePath()}${logoutPath()}`,
182
+ url: this.getLogoutUrl(),
166
183
  }).then((response) => {
167
184
  // clear cache because of cached contributions
168
185
  Cache.clear();
@@ -12,6 +12,7 @@ export type Props = {
12
12
  +error: Error,
13
13
  };
14
14
 
15
+ // $FlowFixMe
15
16
  const StyledBoundary: StyledComponent<{}, Theme, *> = styled.div`
16
17
  padding: ${spacers(2, 1)};
17
18
  margin-bottom: ${spacer(2)};
@@ -19,6 +20,7 @@ const StyledBoundary: StyledComponent<{}, Theme, *> = styled.div`
19
20
  border-radius: 0.3em;
20
21
  `;
21
22
 
23
+ // $FlowFixMe
22
24
  const StyledStack = styled.pre`
23
25
  display: block;
24
26
  font-size: 87.5%;
@@ -176,6 +176,8 @@ const setApplication = (store: ReduxStore) => {
176
176
  locale: locale,
177
177
  }).fetchSync();
178
178
 
179
+ application.connectKey = `application(/)(${locale})`;
180
+
179
181
  store.dispatch(
180
182
  initModels([
181
183
  {
@@ -128,6 +128,11 @@ export namespace ATTRIBUTE_WIDTH {
128
128
  const EXTRA_LARGE: string;
129
129
  }
130
130
  export const ALL_CONTENT_IN_DATA_SETTING: "hasAllContentInData";
131
+ export namespace INTERNAL_LOGIN_TYPE {
132
+ const JAAS: string;
133
+ const PAC4J_FORM: string;
134
+ const PAC4J_BASIC: string;
135
+ }
131
136
  export const LOGIN_TYPE: "security.clients";
132
137
  export const LOGIN_PATH_SETTING: "FormClient.login_url";
133
138
  export const LOGIN_USERNAME_SETTING: "FormClient.username_field_name";
@@ -5,7 +5,11 @@ declare class Authenticate {
5
5
  _isBasic: boolean;
6
6
  /**
7
7
  */
8
- get authenticationType(): "JAAS" | "PAC4J_FORM" | "PAC4J_BASIC";
8
+ get authenticationType(): $Keys<{
9
+ JAAS: string;
10
+ PAC4J_FORM: string;
11
+ PAC4J_BASIC: string;
12
+ }>;
9
13
  /**
10
14
  */
11
15
  set isBasicAuthentication(arg: boolean);
@@ -36,6 +40,9 @@ declare class Authenticate {
36
40
  /**
37
41
  */
38
42
  doJaasAuthentication(username: string, password: string): Promise<any>;
43
+ /**
44
+ */
45
+ getLogoutUrl(): string;
39
46
  /**
40
47
  */
41
48
  logout(): Promise<any>;