@beinformed/ui 1.63.12 → 1.63.14

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.63.14](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.13...v1.63.14) (2025-12-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **authentication:** handle errors during sign-in process ([b4e8c67](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/b4e8c6710b5e2e6e10bb55d7836dba9560fb6e6e))
11
+
12
+ ## [1.63.13](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.12...v1.63.13) (2025-12-09)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **authentication:** cache `primaryAuthenticationType` for use in session ([158e7e8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/158e7e8b810ad257653ae23489cfded365e6784c))
18
+
5
19
  ## [1.63.12](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.11...v1.63.12) (2025-12-08)
6
20
 
7
21
 
@@ -115,7 +115,12 @@ describe("authentication hooks", () => {
115
115
  return res.status(200).body({ data: "ok" });
116
116
  });
117
117
 
118
- const store = mockStore({ auth: {}, i18n: { locale: "en" } });
118
+ const store = mockStore({
119
+ auth: {},
120
+ modularui: {},
121
+ router: { location: {} },
122
+ i18n: { locale: "en" },
123
+ });
119
124
 
120
125
  /**
121
126
  */
@@ -135,6 +140,14 @@ describe("authentication hooks", () => {
135
140
 
136
141
  expect(store.getActions()).toStrictEqual([
137
142
  { type: "START_PROGRESS" },
143
+ expect.objectContaining({
144
+ type: "MODULARUI/FETCH",
145
+ payload: expect.objectContaining({
146
+ key: "application(/)(en)",
147
+ }),
148
+ }),
149
+ { type: "START_PROGRESS" },
150
+ { type: "FINISH_PROGRESS" },
138
151
  { type: "MODULARUI/RESET" },
139
152
  { type: "START_PROGRESS" },
140
153
  expect.objectContaining({
@@ -1,8 +1,7 @@
1
1
  import { useSelector, useDispatch } from "react-redux";
2
- import { getApplication } from "../redux/_modularui/ModularUISelectors";
3
2
  import { login, logout, resetAuthErrors } from "../redux/actions";
4
3
  import Cache from "../utils/browser/Cache";
5
- import { DEFAULT_AUTHENTICATION_TYPE, getBasePath, getBasePathServer, INTERNAL_LOGIN_TYPE } from "../constants";
4
+ import { getBasePath, getBasePathServer, INTERNAL_LOGIN_TYPE } from "../constants";
6
5
  import { IllegalStateException } from "../exceptions";
7
6
  import { Authenticate } from "../modularui";
8
7
  import { useApplication } from "./useModularUIModel";
@@ -14,9 +13,11 @@ export const useLogin = () => {
14
13
  const application = useApplication();
15
14
  const auth = useSelector(state => state.auth);
16
15
  const isAuthenticated = application?.isLoggedIn ?? false;
16
+ const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
17
17
  return {
18
18
  isAuthenticated,
19
- authenticationTypes: application?.authenticationTypes ?? [DEFAULT_AUTHENTICATION_TYPE],
19
+ primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
20
+ authenticationTypes: application?.authenticationTypes ?? [],
20
21
  errorMessage: auth.error,
21
22
  resetErrors: () => dispatch(resetAuthErrors()),
22
23
  login: (username, password) => dispatch(login(username, password)),
@@ -37,13 +38,15 @@ export const useLogin = () => {
37
38
  */
38
39
  export const useLogout = () => {
39
40
  const dispatch = useDispatch();
40
- const application = useSelector(getApplication);
41
+ const application = useApplication();
41
42
  const BASE_PATH = getBasePath();
42
43
  const authenticate = new Authenticate();
44
+ const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
43
45
  const isAuthenticated = application?.isLoggedIn ?? false;
44
46
  return {
45
47
  isAuthenticated,
46
- authenticationTypes: application?.authenticationTypes ?? [DEFAULT_AUTHENTICATION_TYPE],
48
+ primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
49
+ authenticationTypes: application?.authenticationTypes ?? [],
47
50
  logout: () => {
48
51
  const type = authenticate.authenticationType;
49
52
  if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
@@ -1,12 +1,10 @@
1
1
  // @flow
2
2
  import { useSelector, useDispatch } from "react-redux";
3
3
 
4
- import { getApplication } from "../redux/_modularui/ModularUISelectors";
5
4
  import { login, logout, resetAuthErrors } from "../redux/actions";
6
5
 
7
6
  import Cache from "../utils/browser/Cache";
8
7
  import {
9
- DEFAULT_AUTHENTICATION_TYPE,
10
8
  getBasePath,
11
9
  getBasePathServer,
12
10
  INTERNAL_LOGIN_TYPE,
@@ -20,6 +18,7 @@ import type { AuthenticationType } from "../models/types";
20
18
 
21
19
  type LoginHook = {
22
20
  isAuthenticated: boolean,
21
+ primaryAuthenticationType: AuthenticationType,
23
22
  authenticationTypes: Array<AuthenticationType>,
24
23
  errorMessage: ?string,
25
24
  resetErrors: () => ResetAuthErrorsAction,
@@ -28,6 +27,7 @@ type LoginHook = {
28
27
  };
29
28
  type LogoutHook = {
30
29
  isAuthenticated: boolean,
30
+ primaryAuthenticationType: AuthenticationType,
31
31
  authenticationTypes: Array<AuthenticationType>,
32
32
  logout: () => void,
33
33
  logoutUrl: string,
@@ -45,11 +45,13 @@ export const useLogin = (): LoginHook => {
45
45
 
46
46
  const isAuthenticated = application?.isLoggedIn ?? false;
47
47
 
48
+ const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
49
+
48
50
  return {
49
51
  isAuthenticated,
50
- authenticationTypes: application?.authenticationTypes ?? [
51
- DEFAULT_AUTHENTICATION_TYPE,
52
- ],
52
+ primaryAuthenticationType:
53
+ primaryAuthenticationType ?? application?.authenticationTypes[0],
54
+ authenticationTypes: application?.authenticationTypes ?? [],
53
55
  errorMessage: auth.error,
54
56
  resetErrors: () => dispatch(resetAuthErrors()),
55
57
  login: (username: string, password: string) =>
@@ -78,18 +80,21 @@ export const useLogin = (): LoginHook => {
78
80
  */
79
81
  export const useLogout = (): LogoutHook => {
80
82
  const dispatch = useDispatch();
81
- const application = useSelector(getApplication);
83
+
84
+ const application = useApplication();
82
85
 
83
86
  const BASE_PATH = getBasePath();
84
87
 
85
88
  const authenticate = new Authenticate();
86
89
 
90
+ const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
91
+
87
92
  const isAuthenticated = application?.isLoggedIn ?? false;
88
93
  return {
89
94
  isAuthenticated,
90
- authenticationTypes: application?.authenticationTypes ?? [
91
- DEFAULT_AUTHENTICATION_TYPE,
92
- ],
95
+ primaryAuthenticationType:
96
+ primaryAuthenticationType ?? application?.authenticationTypes[0],
97
+ authenticationTypes: application?.authenticationTypes ?? [],
93
98
  logout: () => {
94
99
  const type = authenticate.authenticationType;
95
100
  if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","getApplication","login","logout","resetAuthErrors","Cache","DEFAULT_AUTHENTICATION_TYPE","getBasePath","getBasePathServer","INTERNAL_LOGIN_TYPE","IllegalStateException","Authenticate","useApplication","useLogin","setItem","dispatch","application","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","errorMessage","error","resetErrors","username","password","redirectLogin","authenticationType","getItem","authentication","redirectUri","window","location","assign","useLogout","BASE_PATH","authenticate","type","PAC4J_INDIRECT","redirectToLogout","origin","url","getLogoutUrl","logoutUrl"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n DEFAULT_AUTHENTICATION_TYPE,\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\nimport { useApplication } from \"./useModularUIModel\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n logoutUrl: string,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useApplication();\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`,\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${getBasePathServer()}${authenticationType.redirectUri ?? \"\"}`,\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n const application = useSelector(getApplication);\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\n logout: () => {\n const type = authenticate.authenticationType;\n if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {\n authenticate.redirectToLogout();\n } else if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.getLogoutUrl(),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAEtD,SAASC,cAAc,QAAQ,wCAAwC;AACvE,SAASC,KAAK,EAAEC,MAAM,EAAEC,eAAe,QAAQ,kBAAkB;AAEjE,OAAOC,KAAK,MAAM,wBAAwB;AAC1C,SACEC,2BAA2B,EAC3BC,WAAW,EACXC,iBAAiB,EACjBC,mBAAmB,QACd,cAAc;AACrB,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,cAAc,QAAQ,qBAAqB;AAoBpD;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAiB;EACvCR,KAAK,CAACS,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ,GAAGf,WAAW,CAAC,CAAC;EAE9B,MAAMgB,WAAW,GAAGJ,cAAc,CAAC,CAAC;EACpC,MAAMK,IAAI,GAAGlB,WAAW,CAAEmB,KAAK,IAAKA,KAAK,CAACD,IAAI,CAAC;EAE/C,MAAME,eAAe,GAAGH,WAAW,EAAEI,UAAU,IAAI,KAAK;EAExD,OAAO;IACLD,eAAe;IACfE,mBAAmB,EAAEL,WAAW,EAAEK,mBAAmB,IAAI,CACvDf,2BAA2B,CAC5B;IACDgB,YAAY,EAAEL,IAAI,CAACM,KAAK;IACxBC,WAAW,EAAEA,CAAA,KAAMT,QAAQ,CAACX,eAAe,CAAC,CAAC,CAAC;IAC9CF,KAAK,EAAEA,CAACuB,QAAgB,EAAEC,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AGT,MAAM,CAACC,QAAQ,CAACQ,MAAM;QACrC,MAAMC,GAAG,GAAG,GAAGL,YAAY,CAACM,YAAY,CAAC,CAAC,QAAQF,MAAM,GAAGL,SAAS,EAAE;QACtE/B,KAAK,CAACS,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCkB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACQ,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAO3B,QAAQ,CAACZ,MAAM,CAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDyC,SAAS,EAAEP,YAAY,CAACM,YAAY,CAAC;EACvC,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","login","logout","resetAuthErrors","Cache","getBasePath","getBasePathServer","INTERNAL_LOGIN_TYPE","IllegalStateException","Authenticate","useApplication","useLogin","setItem","dispatch","application","auth","state","isAuthenticated","isLoggedIn","primaryAuthenticationType","getItem","authenticationTypes","errorMessage","error","resetErrors","username","password","redirectLogin","authenticationType","authentication","redirectUri","window","location","assign","useLogout","BASE_PATH","authenticate","type","PAC4J_INDIRECT","redirectToLogout","origin","url","getLogoutUrl","logoutUrl"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\nimport { useApplication } from \"./useModularUIModel\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n logoutUrl: string,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useApplication();\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`,\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${getBasePathServer()}${authenticationType.redirectUri ?? \"\"}`,\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n\n const application = useApplication();\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n logout: () => {\n const type = authenticate.authenticationType;\n if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {\n authenticate.redirectToLogout();\n } else if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.getLogoutUrl(),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAEtD,SAASC,KAAK,EAAEC,MAAM,EAAEC,eAAe,QAAQ,kBAAkB;AAEjE,OAAOC,KAAK,MAAM,wBAAwB;AAC1C,SACEC,WAAW,EACXC,iBAAiB,EACjBC,mBAAmB,QACd,cAAc;AACrB,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,cAAc,QAAQ,qBAAqB;AAsBpD;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CAAA,KAAiB;EACvCP,KAAK,CAACQ,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ,GAAGb,WAAW,CAAC,CAAC;EAE9B,MAAMc,WAAW,GAAGJ,cAAc,CAAC,CAAC;EACpC,MAAMK,IAAI,GAAGhB,WAAW,CAAEiB,KAAK,IAAKA,KAAK,CAACD,IAAI,CAAC;EAE/C,MAAME,eAAe,GAAGH,WAAW,EAAEI,UAAU,IAAI,KAAK;EAExD,MAAMC,yBAAyB,GAAGf,KAAK,CAACgB,OAAO,CAAC,2BAA2B,CAAC;EAE5E,OAAO;IACLH,eAAe;IACfE,yBAAyB,EACvBA,yBAAyB,IAAIL,WAAW,EAAEO,mBAAmB,CAAC,CAAC,CAAC;IAClEA,mBAAmB,EAAEP,WAAW,EAAEO,mBAAmB,IAAI,EAAE;IAC3DC,YAAY,EAAEP,IAAI,CAACQ,KAAK;IACxBC,WAAW,EAAEA,CAAA,KAAMX,QAAQ,CAACV,eAAe,CAAC,CAAC,CAAC;IAC9CF,KAAK,EAAEA,CAACwB,QAAgB,EAAEC,Q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,YAAY,CAACG,gBAAgB,CAAC,CAAC;MACjC,CAAC,MAAM,IAAInC,KAAK,CAACgB,OAAO,CAAC,iBAAiB,CAAC,EAAE;QAC3C,MAAMoB,MAAM,GAAGT,MAAM,CAACC,QAAQ,CAACQ,MAAM;QACrC,MAAMC,GAAG,GAAG,GAAGL,YAAY,CAACM,YAAY,CAAC,CAAC,QAAQF,MAAM,GAAGL,SAAS,EAAE;QACtE/B,KAAK,CAACQ,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCmB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACQ,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAO5B,QAAQ,CAACX,MAAM,CAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDyC,SAAS,EAAEP,YAAY,CAACM,YAAY,CAAC;EACvC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -6,14 +6,19 @@ import LinkModel from "../links/LinkModel";
6
6
  import UserServicesModel from "../user/UserServicesModel";
7
7
  import { NotAllowedUriException } from "../../exceptions";
8
8
  import { DEFAULT_AUTHENTICATION_TYPE } from "../../constants";
9
+ import Cache from "../../utils/browser/Cache";
9
10
  /**
10
11
  * The Application model
11
12
  */
12
13
  export default class ApplicationModel extends ResourceModel {
13
- constructor(...args) {
14
- super(...args);
14
+ constructor(modularuiResponse) {
15
+ super(modularuiResponse);
16
+
17
+ // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
15
18
  _defineProperty(this, "_userServices", void 0);
19
+ Cache.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
16
20
  }
21
+
17
22
  /**
18
23
  * Retrieve type of model
19
24
  */
@@ -72,6 +77,14 @@ export default class ApplicationModel extends ResourceModel {
72
77
  return [DEFAULT_AUTHENTICATION_TYPE];
73
78
  }
74
79
 
80
+ /**
81
+ * Returns the primary authentication type
82
+ * @returns {AuthenticationType}
83
+ */
84
+ get primaryAuthenticationType() {
85
+ return this.authenticationTypes[0];
86
+ }
87
+
75
88
  /**
76
89
  * Getting the tab links
77
90
  */
@@ -7,6 +7,8 @@ import { NotAllowedUriException } from "../../exceptions";
7
7
 
8
8
  import { DEFAULT_AUTHENTICATION_TYPE } from "../../constants";
9
9
 
10
+ import Cache from "../../utils/browser/Cache";
11
+
10
12
  import type { ModularUIModel, AuthenticationType } from "../types";
11
13
  import type { ModularUIResponse } from "../../modularui";
12
14
  import type LinkCollection from "../links/LinkCollection";
@@ -18,6 +20,13 @@ import type Href from "../href/Href";
18
20
  export default class ApplicationModel extends ResourceModel {
19
21
  _userServices: ?UserServicesModel;
20
22
 
23
+ constructor(modularuiResponse: ModularUIResponse) {
24
+ super(modularuiResponse);
25
+
26
+ // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
27
+ Cache.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
28
+ }
29
+
21
30
  /**
22
31
  * Retrieve type of model
23
32
  */
@@ -91,6 +100,14 @@ export default class ApplicationModel extends ResourceModel {
91
100
  return [DEFAULT_AUTHENTICATION_TYPE];
92
101
  }
93
102
 
103
+ /**
104
+ * Returns the primary authentication type
105
+ * @returns {AuthenticationType}
106
+ */
107
+ get primaryAuthenticationType(): AuthenticationType {
108
+ return this.authenticationTypes[0];
109
+ }
110
+
94
111
  /**
95
112
  * Getting the tab links
96
113
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationModel.js","names":["ResourceModel","LinkModel","UserServicesModel","NotAllowedUriException","DEFAULT_AUTHENTICATION_TYPE","ApplicationModel","constructor","args","_defineProperty","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","setChildModels","models","userServiceModel","_findInstanceProperty","call","model","userServices","label","getContribution","authenticationTypes","_context","Function","bind","_sortInstanceProperty","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","create","modelOptions","_userServices","isLoggedIn","userHref","userLink","userMustChangePassword","mustChangePassword"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\",\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\",\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1,\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\n \"modelcatalog\",\n \"/modelcatalog\",\n \"Model catalog\",\n this.modelOptions,\n );\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices?.userLink) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get userMustChangePassword(): boolean {\n return this.userServices?.mustChangePassword ?? false;\n }\n}\n"],"mappings":";;;AACA,OAAOA,aAAa,MAAM,uBAAuB;AACjD,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,iBAAiB,MAAM,2BAA2B;AAEzD,SAASC,sBAAsB,QAAQ,kBAAkB;AAEzD,SAASC,2BAA2B,QAAQ,iBAAiB;AAO7D;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASL,aAAa,CAAC;EAAAM,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAAC,eAAA;EAAA;EAG1D;AACF;AACA;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,aAAa;EACtB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,kBAAkB;EAC3B;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,aAAa;EAErD;;EAEA;AACF;EACEC,yBAAyBA,CAAA,EAAqB;IAC5C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ACrB,KAAK,CAACsB,eAAe,CAAC,KAAK,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,YAAYA,CAAA,EAAc;IAC5B,OAAOvC,SAAS,CAACwC,MAAM,CACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,IAAI,CAACC,YACP,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIf,YAAYA,CAACD,KAAsB,EAAE;IACvC,IAAI,CAACiB,aAAa,GAAGjB,KAAK,YAAYxB,iBAAiB,GAAGwB,KAAK,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIC,YAAYA,CAAA,EAAuB;IACrC,OAAO,IAAI,CAACgB,aAAa,GAAG,IAAI,CAACA,aAAa,GAAG,IAAI;EACvD;;EAEA;AACF;AACA;EACE,IAAIC,UAAUA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACjB,YAAY,EAAEiB,UAAU,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAAgB;IAC1B,IAAI,IAAI,CAAClB,YAAY,EAAEmB,QAAQ,EAAE;MAC/B,OAAO,IAAI,CAACnB,YAAY,CAACmB,QAAQ,CAAC3B,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAI4B,sBAAsBA,CAAA,EAAY;IACpC,OAAO,IAAI,CAACpB,YAAY,EAAEqB,kBAAkB,IAAI,KAAK;EACvD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ApplicationModel.js","names":["ResourceModel","LinkModel","UserServicesModel","NotAllowedUriException","DEFAULT_AUTHENTICATION_TYPE","Cache","ApplicationModel","constructor","modularuiResponse","_defineProperty","setItem","primaryAuthenticationType","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","setChildModels","models","userServiceModel","_findInstanceProperty","call","model","userServices","label","getContribution","authenticationTypes","_context","Function","bind","_sortInstanceProperty","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","create","modelOptions","_userServices","isLoggedIn","userHref","userLink","userMustChangePassword","mustChangePassword"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)\n Cache.setItem(\"primaryAuthenticationType\", this.primaryAuthenticationType);\n }\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\",\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\",\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1,\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Returns the primary authentication type\n * @returns {AuthenticationType}\n */\n get primaryAuthenticationType(): AuthenticationType {\n return this.authenticationTypes[0];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\n \"modelcatalog\",\n \"/modelcatalog\",\n \"Model catalog\",\n this.modelOptions,\n );\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices?.userLink) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get userMustChangePassword(): boolean {\n return this.userServices?.mustChangePassword ?? false;\n }\n}\n"],"mappings":";;;AACA,OAAOA,aAAa,MAAM,uBAAuB;AACjD,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,OAAOC,iBAAiB,MAAM,2BAA2B;AAEzD,SAASC,sBAAsB,QAAQ,kBAAkB;AAEzD,SAASC,2BAA2B,QAAQ,iBAAiB;AAE7D,OAAOC,KAAK,MAAM,2BAA2B;AAO7C;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASN,aAAa,CAA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E,IAAIC,QAAQA,CAAA,EAAgB;IAC1B,IAAI,IAAI,CAAClB,YAAY,EAAEmB,QAAQ,EAAE;MAC/B,OAAO,IAAI,CAACnB,YAAY,CAACmB,QAAQ,CAAC3B,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAI4B,sBAAsBA,CAAA,EAAY;IACpC,OAAO,IAAI,CAACpB,YAAY,EAAEqB,kBAAkB,IAAI,KAAK;EACvD;AACF","ignoreList":[]}
@@ -2,6 +2,7 @@ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
2
2
  import Cache from "../../utils/browser/Cache";
3
3
  import Authenticate from "../../modularui/Authenticate";
4
4
  import { getApplication } from "../_modularui/ModularUISelectors";
5
+ import { handleError } from "./Error";
5
6
  import { reloadApplication } from "./Application";
6
7
  import { startProgress, finishProgress } from "./ProgressIndicator";
7
8
  import { push } from "../_router/RouterActions";
@@ -71,7 +72,7 @@ export const login = (username, password) => (dispatch, getState) => {
71
72
  });
72
73
  }
73
74
  dispatch(loginFailed(error.id));
74
- return dispatch(finishProgress());
75
+ return dispatch(handleError(error));
75
76
  });
76
77
  };
77
78
  //# sourceMappingURL=SignIn.js.map
@@ -3,9 +3,10 @@ import Cache from "../../utils/browser/Cache";
3
3
  import Authenticate from "../../modularui/Authenticate";
4
4
  import { getApplication } from "../_modularui/ModularUISelectors";
5
5
 
6
+ import { handleError } from "./Error";
6
7
  import { reloadApplication } from "./Application";
7
-
8
8
  import { startProgress, finishProgress } from "./ProgressIndicator";
9
+
9
10
  import { push } from "../_router/RouterActions";
10
11
  import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
11
12
 
@@ -97,6 +98,6 @@ export const login =
97
98
  }
98
99
 
99
100
  dispatch(loginFailed(error.id));
100
- return dispatch(finishProgress());
101
+ return dispatch(handleError(error));
101
102
  });
102
103
  };
@@ -1 +1 @@
1
- {"version":3,"file":"SignIn.js","names":["Cache","Authenticate","getApplication","reloadApplication","startProgress","finishProgress","push","CHANGEPASSWORD_PATH","loginFailed","errorMessage","sendAuthenticationError","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","login","username","password","then","addItem","application","userMustChangePassword","catch","error","id","dispatchedReloadApplication","_Promise","resolve"],"sources":["../../../src/redux/actions/SignIn.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\nimport { getApplication } from \"../_modularui/ModularUISelectors\";\n\nimport { reloadApplication } from \"./Application\";\n\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\nimport { push } from \"../_router/RouterActions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n SendAuthenticationErrorAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (\n errorMessage: string,\n): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);\n\n/**\n * Send authentication error action\n */\nexport const sendAuthenticationError = (\n errorMessage: string,\n): SendAuthenticationErrorAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n }),\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch, getState) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n const application = getApplication(getState());\n if (application?.userMustChangePassword) {\n dispatch(changePassword());\n } else {\n dispatch(loginSuccess());\n }\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(changePassword());\n return dispatch(finishProgress());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(finishProgress());\n });\n };\n"],"mappings":";AACA,OAAOA,KAAK,MAAM,2BAA2B;AAC7C,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SAASC,cAAc,QAAQ,kCAAkC;AAEjE,SAASC,iBAAiB,QAAQ,eAAe;AAEjD,SAASC,aAAa,EAAEC,cAAc,QAAQ,qBAAqB;AACnE,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,mBAAmB,QAAQ,2BAA2B;AAS/D;AACA;AACA;AACA,OAAO,MAAMC,WAAW,GACtBC,YAAoB,IACcC,uBAAuB,CAACD,YAAY,CAAC;;AAEzE;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAClCD,YAAoB,KACe;EACnCE,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMI,eAAe,GAAGA,CAAA,MAA8B;EAC3DF,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMG,YAAY,GAAGA,CAAA,MAA2B;EACrDH,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMI,cAAc,GAAGA,CAAA,KAAmB,CAACC,QAAQ,EAAEC,QAAQ,KAAK;EACvED,QAAQ,CAAC;IACPL,IAAI,EAAE;EACR,CAAC,CAAC;EAEF,MAAMO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jE,OAAOiC,QAAA,CAAQC,OAAO,CAACF,2BAA2B,CAAC,CAACP,IAAI,CAAC,MAAM;QAC7D5B,KAAK,CAAC6B,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;QAC3Bb,QAAQ,CAACD,cAAc,CAAC,CAAC,CAAC;QAC1B,OAAOC,QAAQ,CAACX,cAAc,CAAC,CAAC,CAAC;MACnC,CAAC,CAAC;IACJ;IAEAW,QAAQ,CAACR,WAAW,CAACyB,KAAK,CAACC,EAAE,CAAC,CAAC;IAC/B,OAAOlB,QAAQ,CAACX,cAAc,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"SignIn.js","names":["Cache","Authenticate","getApplication","handleError","reloadApplication","startProgress","finishProgress","push","CHANGEPASSWORD_PATH","loginFailed","errorMessage","sendAuthenticationError","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","login","username","password","then","addItem","application","userMustChangePassword","catch","error","id","dispatchedReloadApplication","_Promise","resolve"],"sources":["../../../src/redux/actions/SignIn.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\nimport { getApplication } from \"../_modularui/ModularUISelectors\";\n\nimport { handleError } from \"./Error\";\nimport { reloadApplication } from \"./Application\";\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\n\nimport { push } from \"../_router/RouterActions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n SendAuthenticationErrorAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (\n errorMessage: string,\n): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);\n\n/**\n * Send authentication error action\n */\nexport const sendAuthenticationError = (\n errorMessage: string,\n): SendAuthenticationErrorAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n }),\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch, getState) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n const application = getApplication(getState());\n if (application?.userMustChangePassword) {\n dispatch(changePassword());\n } else {\n dispatch(loginSuccess());\n }\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(changePassword());\n return dispatch(finishProgress());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(handleError(error));\n });\n };\n"],"mappings":";AACA,OAAOA,KAAK,MAAM,2BAA2B;AAC7C,OAAOC,YAAY,MAAM,8BAA8B;AACvD,SAASC,cAAc,QAAQ,kCAAkC;AAEjE,SAASC,WAAW,QAAQ,SAAS;AACrC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,aAAa,EAAEC,cAAc,QAAQ,qBAAqB;AAEnE,SAASC,IAAI,QAAQ,0BAA0B;AAC/C,SAASC,mBAAmB,QAAQ,2BAA2B;AAS/D;AACA;AACA;AACA,OAAO,MAAM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AC,CAAC,CACzCyB,IAAI,CAAC,MAAM;IACV7B,KAAK,CAAC8B,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;IAC3B,MAAMC,WAAW,GAAG7B,cAAc,CAACgB,QAAQ,CAAC,CAAC,CAAC;IAC9C,IAAIa,WAAW,EAAEC,sBAAsB,EAAE;MACvCf,QAAQ,CAACD,cAAc,CAAC,CAAC,CAAC;IAC5B,CAAC,MAAM;MACLC,QAAQ,CAACF,YAAY,CAAC,CAAC,CAAC;IAC1B;IACA,OAAOE,QAAQ,CAACX,cAAc,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACD2B,KAAK,CAAEC,KAAK,IAAK;IAChB,IAAIA,KAAK,CAACC,EAAE,KAAK,8BAA8B,EAAE;MAC/C,MAAMC,2BAA2B,GAAGnB,QAAQ,CAACb,iBAAiB,CAAC,CAAC,CAAC;MAEjE,OAAOiC,QAAA,CAAQC,OAAO,CAACF,2BAA2B,CAAC,CAACP,IAAI,CAAC,MAAM;QAC7D7B,KAAK,CAAC8B,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;QAC3Bb,QAAQ,CAACD,cAAc,CAAC,CAAC,CAAC;QAC1B,OAAOC,QAAQ,CAACX,cAAc,CAAC,CAAC,CAAC;MACnC,CAAC,CAAC;IACJ;IAEAW,QAAQ,CAACR,WAAW,CAACyB,KAAK,CAACC,EAAE,CAAC,CAAC;IAC/B,OAAOlB,QAAQ,CAACd,WAAW,CAAC+B,KAAK,CAAC,CAAC;EACrC,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.useLogout = exports.useLogin = void 0;
8
8
  var _reactRedux = require("react-redux");
9
- var _ModularUISelectors = require("../redux/_modularui/ModularUISelectors");
10
9
  var _actions = require("../redux/actions");
11
10
  var _Cache = _interopRequireDefault(require("../utils/browser/Cache"));
12
11
  var _constants = require("../constants");
@@ -21,9 +20,11 @@ const useLogin = () => {
21
20
  const application = (0, _useModularUIModel.useApplication)();
22
21
  const auth = (0, _reactRedux.useSelector)(state => state.auth);
23
22
  const isAuthenticated = application?.isLoggedIn ?? false;
23
+ const primaryAuthenticationType = _Cache.default.getItem("primaryAuthenticationType");
24
24
  return {
25
25
  isAuthenticated,
26
- authenticationTypes: application?.authenticationTypes ?? [_constants.DEFAULT_AUTHENTICATION_TYPE],
26
+ primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
27
+ authenticationTypes: application?.authenticationTypes ?? [],
27
28
  errorMessage: auth.error,
28
29
  resetErrors: () => dispatch((0, _actions.resetAuthErrors)()),
29
30
  login: (username, password) => dispatch((0, _actions.login)(username, password)),
@@ -45,13 +46,15 @@ const useLogin = () => {
45
46
  exports.useLogin = useLogin;
46
47
  const useLogout = () => {
47
48
  const dispatch = (0, _reactRedux.useDispatch)();
48
- const application = (0, _reactRedux.useSelector)(_ModularUISelectors.getApplication);
49
+ const application = (0, _useModularUIModel.useApplication)();
49
50
  const BASE_PATH = (0, _constants.getBasePath)();
50
51
  const authenticate = new _modularui.Authenticate();
52
+ const primaryAuthenticationType = _Cache.default.getItem("primaryAuthenticationType");
51
53
  const isAuthenticated = application?.isLoggedIn ?? false;
52
54
  return {
53
55
  isAuthenticated,
54
- authenticationTypes: application?.authenticationTypes ?? [_constants.DEFAULT_AUTHENTICATION_TYPE],
56
+ primaryAuthenticationType: primaryAuthenticationType ?? application?.authenticationTypes[0],
57
+ authenticationTypes: application?.authenticationTypes ?? [],
55
58
  logout: () => {
56
59
  const type = authenticate.authenticationType;
57
60
  if (type === _constants.INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_ModularUISelectors","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","_useModularUIModel","useLogin","Cache","setItem","dispatch","useDispatch","application","useApplication","auth","useSelector","state","isAuthenticated","isLoggedIn","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","getItem","IllegalStateException","authentication","redirectUri","window","location","assign","getBasePathServer","exports","useLogout","getApplication","BASE_PATH","getBasePath","authenticate","Authenticate","logout","type","INTERNAL_LOGIN_TYPE","PAC4J_INDIRECT","redirectToLogout","origin","url","getLogoutUrl","logoutUrl"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n DEFAULT_AUTHENTICATION_TYPE,\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\nimport { useApplication } from \"./useModularUIModel\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n logoutUrl: string,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useApplication();\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`,\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${getBasePathServer()}${authenticationType.redirectUri ?? \"\"}`,\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n const application = useSelector(getApplication);\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n DEFAULT_AUTHENTICATION_TYPE,\n ],\n logout: () => {\n const type = authenticate.authenticationType;\n if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {\n authenticate.redirectToLogout();\n } else if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.getLogoutUrl(),\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAMA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AAoBA;AACA;AACO,MAAMS,QAAQ,GAAGA,CAAA,KAAiB;EACvCC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ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yB,kCAAc,CAAC;EAE/C,MAAMC,SAAS,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAE/B,MAAMC,YAAY,GAAG,IAAIC,uBAAY,CAAC,CAAC;EAEvC,MAAM3B,eAAe,GAAGL,WAAW,EAAEM,UAAU,IAAI,KAAK;EACxD,OAAO;IACLD,eAAe;IACfE,mBAAmB,EAAEP,WAAW,EAAEO,mBAAmB,IAAI,CACvDC,sCAA2B,CAC5B;IACDyB,MAAM,EAAEA,CAAA,KAAM;MACZ,MAAMC,IAAI,GAAGH,YAAY,CAACd,kBAAkB;MAC5C,IAAIiB,IAAI,KAAKC,8BAAmB,CAACC,cAAc,EAAE;QAC/CL,YAAY,CAACM,gBAAgB,CAAC,CAAC;MACjC,CAAC,MAAM,IAAIzC,cAAK,CAACsB,OAAO,CAAC,iBAAiB,CAAC,EAAE;QAC3C,MAAMoB,MAAM,GAAGhB,MAAM,CAACC,QAAQ,CAACe,MAAM;QACrC,MAAMC,GAAG,GAAG,GAAGR,YAAY,CAACS,YAAY,CAAC,CAAC,QAAQF,MAAM,GAAGT,SAAS,EAAE;QACtEjC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCyB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACe,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAOzC,QAAQ,CAAC,IAAAmC,eAAM,EAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDQ,SAAS,EAAEV,YAAY,CAACS,YAAY,CAAC;EACvC,CAAC;AACH,CAAC;AAACd,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","_useModularUIModel","useLogin","Cache","setItem","dispatch","useDispatch","application","useApplication","auth","useSelector","state","isAuthenticated","isLoggedIn","primaryAuthenticationType","getItem","authenticationTypes","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","IllegalStateException","authentication","redirectUri","window","location","assign","getBasePathServer","exports","useLogout","BASE_PATH","getBasePath","authenticate","Authenticate","logout","type","INTERNAL_LOGIN_TYPE","PAC4J_INDIRECT","redirectToLogout","origin","url","getLogoutUrl","logoutUrl"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n getBasePath,\n getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\nimport { useApplication } from \"./useModularUIModel\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\n\ntype LoginHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n primaryAuthenticationType: AuthenticationType,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n logoutUrl: string,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useApplication();\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`,\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${getBasePathServer()}${authenticationType.redirectUri ?? \"\"}`,\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n\n const application = useApplication();\n\n const BASE_PATH = getBasePath();\n\n const authenticate = new Authenticate();\n\n const primaryAuthenticationType = Cache.getItem(\"primaryAuthenticationType\");\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n primaryAuthenticationType:\n primaryAuthenticationType ?? application?.authenticationTypes[0],\n authenticationTypes: application?.authenticationTypes ?? [],\n logout: () => {\n const type = authenticate.authenticationType;\n if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {\n authenticate.redirectToLogout();\n } else if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.getLogoutUrl(),\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAsBA;AACA;AACO,MAAMQ,QAAQ,GAAGA,CAAA,KAAiB;EACvCC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC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AAA,GAAAA,SAAA","ignoreList":[]}
@@ -13,14 +13,19 @@ var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
13
13
  var _UserServicesModel = _interopRequireDefault(require("../user/UserServicesModel"));
14
14
  var _exceptions = require("../../exceptions");
15
15
  var _constants = require("../../constants");
16
+ var _Cache = _interopRequireDefault(require("../../utils/browser/Cache"));
16
17
  /**
17
18
  * The Application model
18
19
  */
19
20
  class ApplicationModel extends _ResourceModel.default {
20
- constructor(...args) {
21
- super(...args);
21
+ constructor(modularuiResponse) {
22
+ super(modularuiResponse);
23
+
24
+ // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
22
25
  (0, _defineProperty2.default)(this, "_userServices", void 0);
26
+ _Cache.default.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
23
27
  }
28
+
24
29
  /**
25
30
  * Retrieve type of model
26
31
  */
@@ -79,6 +84,14 @@ class ApplicationModel extends _ResourceModel.default {
79
84
  return [_constants.DEFAULT_AUTHENTICATION_TYPE];
80
85
  }
81
86
 
87
+ /**
88
+ * Returns the primary authentication type
89
+ * @returns {AuthenticationType}
90
+ */
91
+ get primaryAuthenticationType() {
92
+ return this.authenticationTypes[0];
93
+ }
94
+
82
95
  /**
83
96
  * Getting the tab links
84
97
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationModel.js","names":["_ResourceModel","_interopRequireDefault","require","_LinkModel","_UserServicesModel","_exceptions","_constants","ApplicationModel","ResourceModel","constructor","args","_defineProperty2","default","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","_find","call","model","userServices","label","getContribution","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","_context","Function","bind","_sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","modelOptions","_userServices","UserServicesModel","isLoggedIn","userHref","userLink","userMustChangePassword","mustChangePassword","exports"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\",\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\",\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1,\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\n \"modelcatalog\",\n \"/modelcatalog\",\n \"Model catalog\",\n this.modelOptions,\n );\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices?.userLink) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get userMustChangePassword(): boolean {\n return this.userServices?.mustChangePassword ?? false;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AAOA;AACA;AACA;AACe,MAAMK,gBAAgB,SAASC,sBAAa,CAAC;EAAAC,YAAA,GAAAC,IAAA;IAAA,SAAAA,IAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA;EAAA;EAG1D;AACF;AACA;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,aAAa;EACtB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,kBAAkB;EAC3B;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,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CAACP,sCAA2B,CAAC;EACtC;;EAEA;AACF;AACA;EACE,IAAIQ,IAAIA,CAAA,EAAmB;IACzB,OAAO,IAAI,CAACvB,KAAK,CAACwB,eAAe,CAAC,KAAK,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,YAAYA,CAAA,EAAc;IAC5B,OAAOC,kBAAS,CAACC,MAAM,CACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,IAAI,CAACC,YACP,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIjB,YAAYA,CAACD,KAAsB,EAAE;IACvC,IAAI,CAACmB,aAAa,GAAGnB,KAAK,YAAYoB,0BAAiB,GAAGpB,KAAK,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIC,YAAYA,CAAA,EAAuB;IACrC,OAAO,IAAI,CAACkB,aAAa,GAAG,IAAI,CAACA,aAAa,GAAG,IAAI;EACvD;;EAEA;AACF;AACA;EACE,IAAIE,UAAUA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACpB,YAAY,EAAEoB,UAAU,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAAgB;IAC1B,IAAI,IAAI,CAACrB,YAAY,EAAEsB,QAAQ,EAAE;MAC/B,OAAO,IAAI,CAACtB,YAAY,CAACsB,QAAQ,CAAC/B,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIgC,sBAAsBA,CAAA,EAAY;IACpC,OAAO,IAAI,CAACvB,YAAY,EAAEwB,kBAAkB,IAAI,KAAK;EACvD;AACF;AAACC,OAAA,CAAA7C,OAAA,GAAAL,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"ApplicationModel.js","names":["_ResourceModel","_interopRequireDefault","require","_LinkModel","_UserServicesModel","_exceptions","_constants","_Cache","ApplicationModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","Cache","setItem","primaryAuthenticationType","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","_find","call","model","userServices","label","getContribution","authenticationTypes","DEFAULT_AUTHENTICATION_TYPE","_context","Function","bind","_sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","modelOptions","_userServices","UserServicesModel","isLoggedIn","userHref","userLink","userMustChangePassword","mustChangePassword","exports"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport { DEFAULT_AUTHENTICATION_TYPE } from \"../../constants\";\n\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)\n Cache.setItem(\"primaryAuthenticationType\", this.primaryAuthenticationType);\n }\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\",\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\",\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n DEFAULT_AUTHENTICATION_TYPE,\n ]);\n\n if (authenticationTypes) {\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1,\n );\n }\n\n return [DEFAULT_AUTHENTICATION_TYPE];\n }\n\n /**\n * Returns the primary authentication type\n * @returns {AuthenticationType}\n */\n get primaryAuthenticationType(): AuthenticationType {\n return this.authenticationTypes[0];\n }\n\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\n \"modelcatalog\",\n \"/modelcatalog\",\n \"Model catalog\",\n this.modelOptions,\n );\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices?.userLink) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get userMustChangePassword(): boolean {\n return this.userServices?.mustChangePassword ?? false;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sB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G,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIC,YAAYA,CAAA,EAAuB;IACrC,OAAO,IAAI,CAACkB,aAAa,GAAG,IAAI,CAACA,aAAa,GAAG,IAAI;EACvD;;EAEA;AACF;AACA;EACE,IAAIE,UAAUA,CAAA,EAAY;IACxB,OAAO,IAAI,CAACpB,YAAY,EAAEoB,UAAU,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAAgB;IAC1B,IAAI,IAAI,CAACrB,YAAY,EAAEsB,QAAQ,EAAE;MAC/B,OAAO,IAAI,CAACtB,YAAY,CAACsB,QAAQ,CAAC/B,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACE,IAAIgC,sBAAsBA,CAAA,EAAY;IACpC,OAAO,IAAI,CAACvB,YAAY,EAAEwB,kBAAkB,IAAI,KAAK;EACvD;AACF;AAACC,OAAA,CAAAhD,OAAA,GAAAL,gBAAA","ignoreList":[]}
@@ -9,6 +9,7 @@ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
9
9
  var _Cache = _interopRequireDefault(require("../../utils/browser/Cache"));
10
10
  var _Authenticate = _interopRequireDefault(require("../../modularui/Authenticate"));
11
11
  var _ModularUISelectors = require("../_modularui/ModularUISelectors");
12
+ var _Error = require("./Error");
12
13
  var _Application = require("./Application");
13
14
  var _ProgressIndicator = require("./ProgressIndicator");
14
15
  var _RouterActions = require("../_router/RouterActions");
@@ -83,7 +84,7 @@ const login = (username, password) => (dispatch, getState) => {
83
84
  });
84
85
  }
85
86
  dispatch(loginFailed(error.id));
86
- return dispatch((0, _ProgressIndicator.finishProgress)());
87
+ return dispatch((0, _Error.handleError)(error));
87
88
  });
88
89
  };
89
90
  exports.login = login;
@@ -1 +1 @@
1
- {"version":3,"file":"SignIn.js","names":["_Cache","_interopRequireDefault","require","_Authenticate","_ModularUISelectors","_Application","_ProgressIndicator","_RouterActions","_Constants","loginFailed","errorMessage","sendAuthenticationError","exports","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","push","CHANGEPASSWORD_PATH","login","username","password","startProgress","Authenticate","then","reloadApplication","Cache","addItem","application","getApplication","userMustChangePassword","finishProgress","catch","error","id","dispatchedReloadApplication","_promise","default","resolve"],"sources":["../../../src/redux/actions/SignIn.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\nimport { getApplication } from \"../_modularui/ModularUISelectors\";\n\nimport { reloadApplication } from \"./Application\";\n\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\nimport { push } from \"../_router/RouterActions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n SendAuthenticationErrorAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (\n errorMessage: string,\n): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);\n\n/**\n * Send authentication error action\n */\nexport const sendAuthenticationError = (\n errorMessage: string,\n): SendAuthenticationErrorAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n }),\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch, getState) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n const application = getApplication(getState());\n if (application?.userMustChangePassword) {\n dispatch(changePassword());\n } else {\n dispatch(loginSuccess());\n }\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(changePassword());\n return dispatch(finishProgress());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(finishProgress());\n });\n };\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AASA;AACA;AACA;AACO,MAAMO,WAAW,GACtBC,YAAoB,IACcC,uBAAuB,CAACD,YAAY,CAAC;;AAEzE;AACA;AACA;AAFAE,OAAA,CAAAH,WAAA,GAAAA,WAAA;AAGO,MAAME,uBAAuB,GAClCD,YAAoB,KACe;EACnCG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AAFAE,OAAA,CAAAD,uBAAA,GAAAA,uBAAA;AAGO,MAAMI,eAAe,GAAGA,CAAA,MAA8B;EAC3DF,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA;AAFAD,OAAA,CAAAG,eAAA,GAAAA,eAAA;AAGO,MAAMC,YAAY,GAAGA,CAAA,MAA2B;EACrDH,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA;AAFAD,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AC1B;IACA,OAAOE,QAAQ,CAAC,IAAAuB,iCAAc,EAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACDC,KAAK,CAAEC,KAAK,IAAK;IAChB,IAAIA,KAAK,CAACC,EAAE,KAAK,8BAA8B,EAAE;MAC/C,MAAMC,2BAA2B,GAAG3B,QAAQ,CAAC,IAAAiB,8BAAiB,EAAC,CAAC,CAAC;MAEjE,OAAOW,QAAA,CAAAC,OAAA,CAAQC,OAAO,CAACH,2BAA2B,CAAC,CAACX,IAAI,CAAC,MAAM;QAC7DE,cAAK,CAACC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;QAC3BnB,QAAQ,CAACD,cAAc,CAAC,CAAC,CAAC;QAC1B,OAAOC,QAAQ,CAAC,IAAAuB,iCAAc,EAAC,CAAC,CAAC;MACnC,CAAC,CAAC;IACJ;IAEAvB,QAAQ,CAACT,WAAW,CAACkC,KAAK,CAACC,EAAE,CAAC,CAAC;IAC/B,OAAO1B,QAAQ,CAAC,IAAAuB,iCAAc,EAAC,CAAC,CAAC;EACnC,CAAC,CAAC;AACN,CAAC;AAAC7B,OAAA,CAAAiB,KAAA,GAAAA,KAAA","ignoreList":[]}
1
+ {"version":3,"file":"SignIn.js","names":["_Cache","_interopRequireDefault","require","_Authenticate","_ModularUISelectors","_Error","_Application","_ProgressIndicator","_RouterActions","_Constants","loginFailed","errorMessage","sendAuthenticationError","exports","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","push","CHANGEPASSWORD_PATH","login","username","password","startProgress","Authenticate","then","reloadApplication","Cache","addItem","application","getApplication","userMustChangePassword","finishProgress","catch","error","id","dispatchedReloadApplication","_promise","default","resolve","handleError"],"sources":["../../../src/redux/actions/SignIn.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\nimport { getApplication } from \"../_modularui/ModularUISelectors\";\n\nimport { handleError } from \"./Error\";\nimport { reloadApplication } from \"./Application\";\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\n\nimport { push } from \"../_router/RouterActions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n SendAuthenticationErrorAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (\n errorMessage: string,\n): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);\n\n/**\n * Send authentication error action\n */\nexport const sendAuthenticationError = (\n errorMessage: string,\n): SendAuthenticationErrorAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n }),\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch, getState) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n const application = getApplication(getState());\n if (application?.userMustChangePassword) {\n dispatch(changePassword());\n } else {\n dispatch(loginSuccess());\n }\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(changePassword());\n return dispatch(finishProgress());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(handleError(error));\n });\n };\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,kBAAA,GAAAL,OAAA;AAEA,IAAAM,cAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AASA;AACA;AACA;AACO,MAAMQ,WAAW,GACtBC,YAAoB,IACcC,uBAAuB,CAACD,YAAY,CAAC;;AAEzE;AACA;AACA;AAFAE,OAAA,CAAAH,WAAA,GAAAA,WAAA;AAGO,MAAME,uBAAuB,GAClCD,YAAoB,KACe;EACnCG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AAFAE,OAAA,CAAAD,uBAAA,GAAAA,uBAAA;AAGO,MAAMI,eAAe,GAAGA,CAAA,MAA8B;EAC3DF,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA;AAFAD,OAAA,CAAAG,eAAA,GAAAA,eAAA;AAGO,MAAMC,YAAY,GAAGA,CAAA,MAA2B;EACrDH,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA;AAFAD,OAAA,CAAAI,YAAA,GAAAA,YAAA;AAGO,MAAMC,cAAc,GAAGA,CAAA,KAAmB,CAACC,QAAQ,EAAEC,QAAQ,KAAK;EACvED,QAAQ,CAAC;IACPL,IAAI,EAAE;EACR,CAAC,CAAC;EAEF,MAAMO,OAAO,GAAGD,QAAQ,CAAC,CAAC,CAACE,MAAM,CAACC,QAAQ,EAAEC,KAAK,EAAEC,KAAK;EACxD,MAAMC,YAAY,GAAGN,QAAQ,CAAC,CAAC,CAACE,MAAM,CA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,IAAI,CAAC,MAAM;QAC7DE,cAAK,CAACC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC;QAC3BnB,QAAQ,CAACD,cAAc,CAAC,CAAC,CAAC;QAC1B,OAAOC,QAAQ,CAAC,IAAAuB,iCAAc,EAAC,CAAC,CAAC;MACnC,CAAC,CAAC;IACJ;IAEAvB,QAAQ,CAACT,WAAW,CAACkC,KAAK,CAACC,EAAE,CAAC,CAAC;IAC/B,OAAO1B,QAAQ,CAAC,IAAA+B,kBAAW,EAACN,KAAK,CAAC,CAAC;EACrC,CAAC,CAAC;AACN,CAAC;AAAC/B,OAAA,CAAAiB,KAAA,GAAAA,KAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.63.12",
3
+ "version": "1.63.14",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "https://support.beinformed.com",
@@ -71,7 +71,7 @@
71
71
  "dependencies": {
72
72
  "@babel/runtime-corejs3": "^7.28.4",
73
73
  "@date-fns/tz": "^1.4.1",
74
- "baseline-browser-mapping": "^2.9.4",
74
+ "baseline-browser-mapping": "^2.9.5",
75
75
  "big.js": "^7.0.1",
76
76
  "date-fns": "^4.1.0",
77
77
  "deepmerge": "^4.3.1",
@@ -115,7 +115,12 @@ describe("authentication hooks", () => {
115
115
  return res.status(200).body({ data: "ok" });
116
116
  });
117
117
 
118
- const store = mockStore({ auth: {}, i18n: { locale: "en" } });
118
+ const store = mockStore({
119
+ auth: {},
120
+ modularui: {},
121
+ router: { location: {} },
122
+ i18n: { locale: "en" },
123
+ });
119
124
 
120
125
  /**
121
126
  */
@@ -135,6 +140,14 @@ describe("authentication hooks", () => {
135
140
 
136
141
  expect(store.getActions()).toStrictEqual([
137
142
  { type: "START_PROGRESS" },
143
+ expect.objectContaining({
144
+ type: "MODULARUI/FETCH",
145
+ payload: expect.objectContaining({
146
+ key: "application(/)(en)",
147
+ }),
148
+ }),
149
+ { type: "START_PROGRESS" },
150
+ { type: "FINISH_PROGRESS" },
138
151
  { type: "MODULARUI/RESET" },
139
152
  { type: "START_PROGRESS" },
140
153
  expect.objectContaining({
@@ -1,12 +1,10 @@
1
1
  // @flow
2
2
  import { useSelector, useDispatch } from "react-redux";
3
3
 
4
- import { getApplication } from "../redux/_modularui/ModularUISelectors";
5
4
  import { login, logout, resetAuthErrors } from "../redux/actions";
6
5
 
7
6
  import Cache from "../utils/browser/Cache";
8
7
  import {
9
- DEFAULT_AUTHENTICATION_TYPE,
10
8
  getBasePath,
11
9
  getBasePathServer,
12
10
  INTERNAL_LOGIN_TYPE,
@@ -20,6 +18,7 @@ import type { AuthenticationType } from "../models/types";
20
18
 
21
19
  type LoginHook = {
22
20
  isAuthenticated: boolean,
21
+ primaryAuthenticationType: AuthenticationType,
23
22
  authenticationTypes: Array<AuthenticationType>,
24
23
  errorMessage: ?string,
25
24
  resetErrors: () => ResetAuthErrorsAction,
@@ -28,6 +27,7 @@ type LoginHook = {
28
27
  };
29
28
  type LogoutHook = {
30
29
  isAuthenticated: boolean,
30
+ primaryAuthenticationType: AuthenticationType,
31
31
  authenticationTypes: Array<AuthenticationType>,
32
32
  logout: () => void,
33
33
  logoutUrl: string,
@@ -45,11 +45,13 @@ export const useLogin = (): LoginHook => {
45
45
 
46
46
  const isAuthenticated = application?.isLoggedIn ?? false;
47
47
 
48
+ const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
49
+
48
50
  return {
49
51
  isAuthenticated,
50
- authenticationTypes: application?.authenticationTypes ?? [
51
- DEFAULT_AUTHENTICATION_TYPE,
52
- ],
52
+ primaryAuthenticationType:
53
+ primaryAuthenticationType ?? application?.authenticationTypes[0],
54
+ authenticationTypes: application?.authenticationTypes ?? [],
53
55
  errorMessage: auth.error,
54
56
  resetErrors: () => dispatch(resetAuthErrors()),
55
57
  login: (username: string, password: string) =>
@@ -78,18 +80,21 @@ export const useLogin = (): LoginHook => {
78
80
  */
79
81
  export const useLogout = (): LogoutHook => {
80
82
  const dispatch = useDispatch();
81
- const application = useSelector(getApplication);
83
+
84
+ const application = useApplication();
82
85
 
83
86
  const BASE_PATH = getBasePath();
84
87
 
85
88
  const authenticate = new Authenticate();
86
89
 
90
+ const primaryAuthenticationType = Cache.getItem("primaryAuthenticationType");
91
+
87
92
  const isAuthenticated = application?.isLoggedIn ?? false;
88
93
  return {
89
94
  isAuthenticated,
90
- authenticationTypes: application?.authenticationTypes ?? [
91
- DEFAULT_AUTHENTICATION_TYPE,
92
- ],
95
+ primaryAuthenticationType:
96
+ primaryAuthenticationType ?? application?.authenticationTypes[0],
97
+ authenticationTypes: application?.authenticationTypes ?? [],
93
98
  logout: () => {
94
99
  const type = authenticate.authenticationType;
95
100
  if (type === INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT) {
@@ -7,6 +7,8 @@ import { NotAllowedUriException } from "../../exceptions";
7
7
 
8
8
  import { DEFAULT_AUTHENTICATION_TYPE } from "../../constants";
9
9
 
10
+ import Cache from "../../utils/browser/Cache";
11
+
10
12
  import type { ModularUIModel, AuthenticationType } from "../types";
11
13
  import type { ModularUIResponse } from "../../modularui";
12
14
  import type LinkCollection from "../links/LinkCollection";
@@ -18,6 +20,13 @@ import type Href from "../href/Href";
18
20
  export default class ApplicationModel extends ResourceModel {
19
21
  _userServices: ?UserServicesModel;
20
22
 
23
+ constructor(modularuiResponse: ModularUIResponse) {
24
+ super(modularuiResponse);
25
+
26
+ // store authentication type in session cache, to make it available when application is no longer available (when not permitted for example)
27
+ Cache.setItem("primaryAuthenticationType", this.primaryAuthenticationType);
28
+ }
29
+
21
30
  /**
22
31
  * Retrieve type of model
23
32
  */
@@ -91,6 +100,14 @@ export default class ApplicationModel extends ResourceModel {
91
100
  return [DEFAULT_AUTHENTICATION_TYPE];
92
101
  }
93
102
 
103
+ /**
104
+ * Returns the primary authentication type
105
+ * @returns {AuthenticationType}
106
+ */
107
+ get primaryAuthenticationType(): AuthenticationType {
108
+ return this.authenticationTypes[0];
109
+ }
110
+
94
111
  /**
95
112
  * Getting the tab links
96
113
  */
@@ -3,9 +3,10 @@ import Cache from "../../utils/browser/Cache";
3
3
  import Authenticate from "../../modularui/Authenticate";
4
4
  import { getApplication } from "../_modularui/ModularUISelectors";
5
5
 
6
+ import { handleError } from "./Error";
6
7
  import { reloadApplication } from "./Application";
7
-
8
8
  import { startProgress, finishProgress } from "./ProgressIndicator";
9
+
9
10
  import { push } from "../_router/RouterActions";
10
11
  import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
11
12
 
@@ -97,6 +98,6 @@ export const login =
97
98
  }
98
99
 
99
100
  dispatch(loginFailed(error.id));
100
- return dispatch(finishProgress());
101
+ return dispatch(handleError(error));
101
102
  });
102
103
  };