@beinformed/ui 1.63.9 → 1.63.11

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,21 @@
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.11](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.9...v1.63.11) (2025-11-27)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **list-detail:** handle given answers without attributes ([36e4ad1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/36e4ad1932dc422ce7d03a9422a10c67e95e9a62))
11
+ * **logout:** use absolute post logout redirect url ([4ddfee8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/4ddfee88748ea97944c74b4d006638e71db89af1))
12
+
13
+ ## [1.63.10](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.9...v1.63.10) (2025-11-25)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **logout:** use absolute post logout redirect url ([4ddfee8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/4ddfee88748ea97944c74b4d006638e71db89af1))
19
+
5
20
  ## [1.63.9](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.63.7...v1.63.9) (2025-11-24)
6
21
 
7
22
 
@@ -2,7 +2,7 @@ import { useSelector, useDispatch } from "react-redux";
2
2
  import { getApplication } from "../redux/_modularui/ModularUISelectors";
3
3
  import { login, logout, resetAuthErrors } from "../redux/actions";
4
4
  import Cache from "../utils/browser/Cache";
5
- import { DEFAULT_AUTHENTICATION_TYPE, getBasePathServer, INTERNAL_LOGIN_TYPE, logoutPath } from "../constants";
5
+ import { DEFAULT_AUTHENTICATION_TYPE, getBasePath, getBasePathServer, INTERNAL_LOGIN_TYPE } from "../constants";
6
6
  import { IllegalStateException } from "../exceptions";
7
7
  import { Authenticate } from "../modularui";
8
8
  /**
@@ -37,8 +37,7 @@ export const useLogin = () => {
37
37
  export const useLogout = () => {
38
38
  const dispatch = useDispatch();
39
39
  const application = useSelector(getApplication);
40
- const LOGOUT_PATH = logoutPath();
41
- const BASE_PATH = getBasePathServer();
40
+ const BASE_PATH = getBasePath();
42
41
  const authenticate = new Authenticate();
43
42
  const isAuthenticated = application?.isLoggedIn ?? false;
44
43
  return {
@@ -50,7 +49,7 @@ export const useLogout = () => {
50
49
  authenticate.redirectToLogout();
51
50
  } else if (Cache.getItem("isRedirectLogin")) {
52
51
  const origin = window.location.origin;
53
- const url = `${origin}${BASE_PATH}/logout?url=${origin}${BASE_PATH}${LOGOUT_PATH}`;
52
+ const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;
54
53
  Cache.setItem("isRedirectLogin", false);
55
54
  window.location.assign(url);
56
55
  } else {
@@ -7,9 +7,9 @@ import { login, logout, resetAuthErrors } from "../redux/actions";
7
7
  import Cache from "../utils/browser/Cache";
8
8
  import {
9
9
  DEFAULT_AUTHENTICATION_TYPE,
10
+ getBasePath,
10
11
  getBasePathServer,
11
12
  INTERNAL_LOGIN_TYPE,
12
- logoutPath,
13
13
  } from "../constants";
14
14
  import { IllegalStateException } from "../exceptions";
15
15
  import { Authenticate } from "../modularui";
@@ -79,8 +79,7 @@ export const useLogout = (): LogoutHook => {
79
79
  const dispatch = useDispatch();
80
80
  const application = useSelector(getApplication);
81
81
 
82
- const LOGOUT_PATH = logoutPath();
83
- const BASE_PATH = getBasePathServer();
82
+ const BASE_PATH = getBasePath();
84
83
 
85
84
  const authenticate = new Authenticate();
86
85
 
@@ -96,7 +95,7 @@ export const useLogout = (): LogoutHook => {
96
95
  authenticate.redirectToLogout();
97
96
  } else if (Cache.getItem("isRedirectLogin")) {
98
97
  const origin = window.location.origin;
99
- const url = `${origin}${BASE_PATH}/logout?url=${origin}${BASE_PATH}${LOGOUT_PATH}`;
98
+ const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;
100
99
  Cache.setItem("isRedirectLogin", false);
101
100
  window.location.assign(url);
102
101
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","getApplication","login","logout","resetAuthErrors","Cache","DEFAULT_AUTHENTICATION_TYPE","getBasePathServer","INTERNAL_LOGIN_TYPE","logoutPath","IllegalStateException","Authenticate","useLogin","setItem","dispatch","application","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","errorMessage","error","resetErrors","username","password","redirectLogin","authenticationType","getItem","authentication","redirectUri","window","location","assign","useLogout","LOGOUT_PATH","BASE_PATH","authenticate","type","PAC4J_INDIRECT","redirectToLogout","origin","url","logoutUrl","getLogoutUrl"],"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 getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n logoutPath,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\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 = useSelector(getApplication);\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 LOGOUT_PATH = logoutPath();\n const BASE_PATH = getBasePathServer();\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 = `${origin}${BASE_PATH}/logout?url=${origin}${BASE_PATH}${LOGOUT_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;A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AC","ignoreList":[]}
1
+ {"version":3,"file":"useAuthentication.js","names":["useSelector","useDispatch","getApplication","login","logout","resetAuthErrors","Cache","DEFAULT_AUTHENTICATION_TYPE","getBasePath","getBasePathServer","INTERNAL_LOGIN_TYPE","IllegalStateException","Authenticate","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\";\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 = useSelector(getApplication);\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;A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d,WAAW,CAAC,CAAC;EAC9B,MAAMe,WAAW,GAAGhB,WAAW,CAACE,cAAc,CAAC;EAE/C,MAAMkC,SAAS,GAAG5B,WAAW,CAAC,CAAC;EAE/B,MAAM6B,YAAY,GAAG,IAAIzB,YAAY,CAAC,CAAC;EAEvC,MAAMO,eAAe,GAAGH,WAAW,EAAEI,UAAU,IAAI,KAAK;EACxD,OAAO;IACLD,eAAe;IACfE,mBAAmB,EAAEL,WAAW,EAAEK,mBAAmB,IAAI,CACvDd,2BAA2B,CAC5B;IACDH,MAAM,EAAEA,CAAA,KAAM;MACZ,MAAMkC,IAAI,GAAGD,YAAY,CAACT,kBAAkB;MAC5C,IAAIU,IAAI,KAAK5B,mBAAmB,CAAC6B,cAAc,EAAE;QAC/CF,YAAY,CAACG,gBAAgB,CAAC,CAAC;MACjC,CAAC,MAAM,IAAIlC,KAAK,CAACuB,OAAO,CAAC,iBAAiB,CAAC,EAAE;QAC3C,MAAMY,MAAM,GAAGT,MAAM,CAACC,QAAQ,CAACQ,MAAM;QACrC,MAAMC,GAAG,GAAG,GAAGL,YAAY,CAACM,YAAY,CAAC,CAAC,QAAQF,MAAM,GAAGL,SAAS,EAAE;QACtE9B,KAAK,CAACQ,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCkB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACQ,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAO3B,QAAQ,CAACX,MAAM,CAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDwC,SAAS,EAAEP,YAAY,CAACM,YAAY,CAAC;EACvC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -174,13 +174,13 @@ export default class ListDetailModel extends DetailModel {
174
174
  var _context2;
175
175
  const givenAnswersData = this.data.resultSection.givenAnswers;
176
176
  const givenAnswersContributions = this.contributions.resultSection.givenAnswers;
177
- const filteredContributions = {
177
+ const filteredContributions = givenAnswersContributions.children ? {
178
178
  ...givenAnswersContributions,
179
179
  children: _filterInstanceProperty(_context2 = givenAnswersContributions.children).call(_context2, child => {
180
180
  const childKey = _Object$keys(child)[0];
181
181
  return childKey in givenAnswersData;
182
182
  })
183
- };
183
+ } : givenAnswersContributions;
184
184
  const givenAnswers = createAttribute("givenAnswers", {
185
185
  key: "givenAnswers",
186
186
  dynamicschema: this.data.dynamicschema,
@@ -219,13 +219,15 @@ export default class ListDetailModel extends DetailModel {
219
219
  const givenAnswersContributions =
220
220
  this.contributions.resultSection.givenAnswers;
221
221
 
222
- const filteredContributions = {
223
- ...givenAnswersContributions,
224
- children: givenAnswersContributions.children.filter((child) => {
225
- const childKey = Object.keys(child)[0];
226
- return childKey in givenAnswersData;
227
- }),
228
- };
222
+ const filteredContributions = givenAnswersContributions.children
223
+ ? {
224
+ ...givenAnswersContributions,
225
+ children: givenAnswersContributions.children.filter((child) => {
226
+ const childKey = Object.keys(child)[0];
227
+ return childKey in givenAnswersData;
228
+ }),
229
+ }
230
+ : givenAnswersContributions;
229
231
 
230
232
  const givenAnswers = createAttribute(
231
233
  "givenAnswers",
@@ -1 +1 @@
1
- {"version":3,"file":"ListDetailModel.js","names":["has","ActionCollection","DetailModel","ContentConfiguration","AttributeSetModel","createAttribute","CompositeAttributeModel","ListDetailModel","constructor","modularUIResponse","_defineProperty","_actionCollection","_contentConfiguration","contributions","content","setResultSection","setEventData","getInitialChildModelLinks","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","givenAnswers","setChildModels","models","errors","_attributeCollection","type","modelName","isApplicableModel","data","resourcetype","toLowerCase","_endsWithInstanceProperty","call","_listitem","actionCollection","panelLinks","contentConfiguration","configuration","introtext","_content","text","message","Array","isArray","texts","setResults","setGivenAnswers","resultsData","resultSection","resultsContributions","_context","children","_filterInstanceProperty","child","childKey","_Object$keys","key","dynamicschema","isResult","indicateContentConfiguration","_results","_context2","givenAnswersData","givenAnswersContributions","filteredContributions","_givenAnswers","hasEventData","eventdata","addAttributes","eventData","eventContributions","_eventdata","modelOptions","forEach","eventDataContribution","eventDataData","i"],"sources":["../../../src/models/list/ListDetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {},\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n\n if (this.results) {\n this.results.setChildModels(models, errors);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models, errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ListDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n let resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n resourcetype = resourcetype.toLowerCase();\n\n return (\n resourcetype.endsWith(\"listdetail\") ||\n resourcetype.endsWith(\"listpaneldetail\") ||\n resourcetype.endsWith(\"datastorepaneldetail\")\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const resultsData = this.data.resultSection.results;\n const resultsContributions = this.contributions.resultSection.results;\n if (resultsContributions.type === \"composite\") {\n resultsContributions.children = resultsContributions.children.filter(\n (child) => {\n const childKey = Object.keys(child)[0];\n return childKey in resultsData;\n },\n );\n }\n\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n resultsContributions,\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions,\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(\n key,\n eventData,\n eventContributions,\n this.modelOptions,\n ),\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"mappings":";;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,WAAW,MAAM,uBAAuB;AAC/C,OAAOC,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,iBAAiB,MAAM,iCAAiC;AAE/D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,uBAAuB,MAAM,uCAAuC;AAS3E;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASL,WAAW,CAAC;EAOvD;AACF;AACA;EACEM,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAEzB,IAAI,CAACC,iBAAiB,GAAG,IAAIV,gBAAgB,CAAC,CAAC;IAE/C,IAAI,CAACW,qBAAqB,GAAG,IAAIT,oBAAoB,CACnD,IAAI,CAACU,aAAa,GAAG,IAAI,CAACA,aAAa,CAACC,OAAO,GAAG,CAAC,CACrD,CAAC;IAED,IAAI,CAACC,gBAAgB,CAAC,CAAC;IACvB,IAAI,CAACC,YAAY,CAAC,CAAC;EACrB;;EAEA;AACF;AACA;EACEC,yBAAyBA,CAAA,EAAqB;IAC5C,MAAMC,cAAc,GAAG,IAAI,CAACC,QAAQ,GAChC,IAAI,CAACA,QAAQ,CAACC,KAAK,CAAC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,CAACE,aAAa,EAAEC,CAAC,KAAK;cACrD,IAAI,CAACR,aAAa,CAChB,GAAGZ,GAAG,IAAIoB,CAAC,GAAG,CAAC,EAAE,EACjB;gBACE,GAAGD,aAAa;gBAChBlB,aAAa,EAAE,IAAI,CAAC7B,IAAI,CAAC6B;cAC3B,CAAC,EACDiB,qBAAqB,CAAClB,GAAG,CAC3B,CAAC;YACH,CAAC,CAAC;UACJ,CAAC,MAAM;YACL,IAAI,CAACY,aAAa,CAChBZ,GAAG,EACH;cACE,GAAG,IAAI,CAAC5B,IAAI,CAACuC,SAAS,CAACX,GAAG,CAAC;cAC3BC,aAAa,EAAE,IAAI,CAAC7B,IAAI,CAAC6B;YAC3B,CAAC,EACDiB,qBAAqB,CAAClB,GAAG,CAC3B,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;EACE,IAAIW,SAASA,CAAA,EAA6B;IACxC,OAAO,IAAI,CAACI,UAAU;EACxB;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ListDetailModel.js","names":["has","ActionCollection","DetailModel","ContentConfiguration","AttributeSetModel","createAttribute","CompositeAttributeModel","ListDetailModel","constructor","modularUIResponse","_defineProperty","_actionCollection","_contentConfiguration","contributions","content","setResultSection","setEventData","getInitialChildModelLinks","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","givenAnswers","setChildModels","models","errors","_attributeCollection","type","modelName","isApplicableModel","data","resourcetype","toLowerCase","_endsWithInstanceProperty","call","_listitem","actionCollection","panelLinks","contentConfiguration","configuration","introtext","_content","text","message","Array","isArray","texts","setResults","setGivenAnswers","resultsData","resultSection","resultsContributions","_context","children","_filterInstanceProperty","child","childKey","_Object$keys","key","dynamicschema","isResult","indicateContentConfiguration","_results","_context2","givenAnswersData","givenAnswersContributions","filteredContributions","_givenAnswers","hasEventData","eventdata","addAttributes","eventData","eventContributions","_eventdata","modelOptions","forEach","eventDataContribution","eventDataData","i"],"sources":["../../../src/models/list/ListDetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {},\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n\n if (this.results) {\n this.results.setChildModels(models, errors);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models, errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ListDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n let resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n resourcetype = resourcetype.toLowerCase();\n\n return (\n resourcetype.endsWith(\"listdetail\") ||\n resourcetype.endsWith(\"listpaneldetail\") ||\n resourcetype.endsWith(\"datastorepaneldetail\")\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const resultsData = this.data.resultSection.results;\n const resultsContributions = this.contributions.resultSection.results;\n if (resultsContributions.type === \"composite\") {\n resultsContributions.children = resultsContributions.children.filter(\n (child) => {\n const childKey = Object.keys(child)[0];\n return childKey in resultsData;\n },\n );\n }\n\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n resultsContributions,\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = givenAnswersContributions.children\n ? {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n }\n : givenAnswersContributions;\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions,\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(\n key,\n eventData,\n eventContributions,\n this.modelOptions,\n ),\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"mappings":";;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,WAAW,MAAM,uBAAuB;AAC/C,OAAOC,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,iBAAiB,MAAM,iCAAiC;AAE/D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,uBAAuB,MAAM,uCAAuC;AAS3E;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASL,WAAW,CAAC;EAOvD;AACF;AACA;EACEM,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAEzB,IAAI,CAACC,iBAAiB,GAAG,IAAIV,gBAAgB,CAAC,CAAC;IAE/C,IAAI,CAACW,qBAAqB,GAAG,IAAIT,oBAAoB,CACnD,IAAI,CAACU,aAAa,GAAG,IAAI,CAACA,aAAa,CAACC,OAAO,GAAG,CAAC,CACrD,CAAC;IAED,IAAI,CAACC,gBAAgB,CAAC,CAAC;IACvB,IAAI,CAACC,YAAY,CAAC,CAAC;EACrB;;EAEA;AACF;AACA;EACEC,yBAAyBA,CAAA,EAAqB;IAC5C,MAAMC,cAAc,GAAG,IAAI,CAACC,QAAQ,GAChC,IAAI,CAACA,QAAQ,CAACC,KAAK,CAACC,eAAe,CAAC,OAAO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G,CAAC,CAACiB,OAAO,CAAC,CAACE,aAAa,EAAEC,CAAC,KAAK;cACrD,IAAI,CAACR,aAAa,CAChB,GAAGZ,GAAG,IAAIoB,CAAC,GAAG,CAAC,EAAE,EACjB;gBACE,GAAGD,aAAa;gBAChBlB,aAAa,EAAE,IAAI,CAAC7B,IAAI,CAAC6B;cAC3B,CAAC,EACDiB,qBAAqB,CAAClB,GAAG,CAC3B,CAAC;YACH,CAAC,CAAC;UACJ,CAAC,MAAM;YACL,IAAI,CAACY,aAAa,CAChBZ,GAAG,EACH;cACE,GAAG,IAAI,CAAC5B,IAAI,CAACuC,SAAS,CAACX,GAAG,CAAC;cAC3BC,aAAa,EAAE,IAAI,CAAC7B,IAAI,CAAC6B;YAC3B,CAAC,EACDiB,qBAAqB,CAAClB,GAAG,CAC3B,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;EACE,IAAIW,SAASA,CAAA,EAA6B;IACxC,OAAO,IAAI,CAACI,UAAU;EACxB;AACF","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
2
2
  import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
3
3
  import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
4
+ import _startsWithInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/starts-with";
4
5
  import { HTTP_METHODS } from "../constants/Constants";
5
6
  import universalFetch from "../utils/fetch/universalFetch";
6
7
  import Cache from "../utils/browser/Cache";
@@ -170,9 +171,11 @@ class Authenticate {
170
171
  /**
171
172
  * Browser redirect to the logout url. (no xmlhttp)
172
173
  */
173
- redirectToLogout(postRedirectUrl) {
174
+ redirectToLogout(postRedirectUrl = "") {
175
+ var _context;
174
176
  Cache.clear();
175
- const redirectUrl = postRedirectUrl || getBasePath();
177
+ const origin = window.location.origin;
178
+ const redirectUrl = ((_context = postRedirectUrl) == null ? void 0 : Function.call.bind(_startsWithInstanceProperty(_context), _context))?.("http") ? postRedirectUrl : `${origin}${getBasePath()}`;
176
179
  window.location.assign(this.getLogoutUrl() + "?url=" + redirectUrl);
177
180
  }
178
181
 
@@ -189,10 +189,13 @@ class Authenticate {
189
189
  /**
190
190
  * Browser redirect to the logout url. (no xmlhttp)
191
191
  */
192
- redirectToLogout(postRedirectUrl?: string): void {
192
+ redirectToLogout(postRedirectUrl: string = ""): void {
193
193
  Cache.clear();
194
194
 
195
- const redirectUrl = postRedirectUrl || getBasePath();
195
+ const origin = window.location.origin;
196
+ const redirectUrl = postRedirectUrl?.startsWith("http")
197
+ ? postRedirectUrl
198
+ : `${origin}${getBasePath()}`;
196
199
 
197
200
  window.location.assign(this.getLogoutUrl() + "?url=" + redirectUrl);
198
201
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Authenticate.js","names":["HTTP_METHODS","universalFetch","Cache","UnauthorizedException","INTERNAL_LOGIN_TYPE","loginType","loginPath","loginPasswordField","loginUsernameField","logoutPath","getBasePath","Authenticate","constructor","_defineProperty","_isBasic","authenticationType","type","JAAS","_includesInstanceProperty","call","PAC4J_FORM","PAC4J_BASIC","PAC4J_INDIRECT","isBasicAuthentication","requestLogin","url","method","GET","headers","Accept","initLogin","_Promise","resolve","catch","error","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","POST","data","addItem","btoa","then","removeItem","getLogoutUrl","redirectToLogout","postRedirectUrl","clear","redirectUrl","window","location","assign","logout","response"],"sources":["../../src/modularui/Authenticate.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport Cache from \"../utils/browser/Cache\";\n\nimport { UnauthorizedException } from \"../exceptions\";\nimport {\n INTERNAL_LOGIN_TYPE,\n loginType,\n loginPath,\n loginPasswordField,\n loginUsernameField,\n logoutPath,\n getBasePath,\n} from \"../constants\";\n\n/**\n */\nclass Authenticate {\n _isBasic: boolean;\n\n /**\n */\n constructor() {\n this._isBasic = false;\n }\n\n /**\n */\n get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return INTERNAL_LOGIN_TYPE.JAAS;\n }\n\n if (type.includes(\"FormClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_FORM;\n } else if (type.includes(\"IndirectBasicClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;\n }\n return INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT;\n }\n\n /**\n */\n get isBasicAuthentication(): boolean {\n return (\n this._isBasic ||\n this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC\n );\n }\n\n /**\n */\n set isBasicAuthentication(isBasicAuthentication: boolean) {\n this._isBasic = isBasicAuthentication;\n }\n\n /**\n */\n requestLogin(): Promise<any> {\n return universalFetch({\n url: `${getBasePath()}/login`,\n method: HTTP_METHODS.GET,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n });\n }\n\n /**\n */\n initLogin(initLogin: boolean): Promise<any> {\n if (this.isBasicAuthentication || !initLogin) {\n return Promise.resolve(true);\n }\n\n return this.requestLogin().catch((error) => {\n // when an unauthorizedexception is received on a request to the login service,\n // this indicates a basic authorization scenario\n // in case of form based authentication other exceptions are thrown\n if (error instanceof UnauthorizedException) {\n this.isBasicAuthentication = true;\n }\n\n return Promise.resolve({});\n });\n }\n\n /**\n */\n login(username: string, password: string): Promise<any> {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return this.doFormLogin(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return this.doBasicAuthentication(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n // pac4j should handle this\n return Promise.resolve();\n default:\n return this.doJaasAuthentication(username, password);\n }\n }\n\n /**\n */\n getFormLoginUrl(): string {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return `${getBasePath()}${loginPath(\"DirectBasicAuthClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath(\"FormClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n //pac4j should handle this\n return \"\";\n default:\n return `${getBasePath()}/j_security_check`;\n }\n }\n\n /**\n */\n getFormLoginData(username: string, password: string): string {\n const encodedUsername = encodeURIComponent(username);\n const encodedPassword = encodeURIComponent(password);\n\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;\n case INTERNAL_LOGIN_TYPE.JAAS:\n return `j_username=${encodedUsername}&j_password=${encodedPassword}`;\n default:\n return \"\";\n }\n }\n\n /**\n */\n doFormLogin(username: string, password: string): Promise<any> {\n return universalFetch({\n url: this.getFormLoginUrl(),\n method: HTTP_METHODS.POST,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n data: this.getFormLoginData(username, password),\n });\n }\n\n /**\n */\n doBasicAuthentication(username: string, password: string): Promise<any> {\n Cache.addItem(\"basic\", btoa(`${username}:${password}`));\n return this.requestLogin();\n }\n\n /**\n */\n doJaasAuthentication(username: string, password: string): Promise<any> {\n return this.initLogin(true).then(() => {\n if (this.isBasicAuthentication) {\n Cache.removeItem(\"basic-ok\");\n return this.doBasicAuthentication(username, password).then(() => {\n Cache.addItem(\"basic-ok\", true);\n });\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n getLogoutUrl(): string {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return `${getBasePath()}/Logoff`;\n }\n\n return `${getBasePath()}${logoutPath()}`;\n }\n\n /**\n * Browser redirect to the logout url. (no xmlhttp)\n */\n redirectToLogout(postRedirectUrl?: string): void {\n Cache.clear();\n\n const redirectUrl = postRedirectUrl || getBasePath();\n\n window.location.assign(this.getLogoutUrl() + \"?url=\" + redirectUrl);\n }\n\n /**\n * Logout the user with xmlhttp\n */\n logout(): Promise<any> {\n return universalFetch({\n url: this.getLogoutUrl(),\n }).then((response) => {\n // clear cache because of cached contributions\n Cache.clear();\n return response;\n });\n }\n}\n\nexport default Authenticate;\n"],"mappings":";;;AACA,SAASA,YAAY,QAAQ,wBAAwB;AAErD,OAAOC,cAAc,MAAM,+BAA+B;AAC1D,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SACEC,mBAAmB,EACnBC,SAAS,EACTC,SAAS,EACTC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,WAAW,QACN,cAAc;;AAErB;AACA;AACA,MAAMC,YAAY,CAAC;EAGjB;AACF;EACEC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IACZ,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;;EAEA;AACF;EACE,IAAIC,kBAAkBA,CAAA,EAAsC;IAC1D,MAAMC,IAAI,GAAGX,SAAS,CAAC,CAAC;IAExB,IAAI,CAACW,IAAI,IAAIA,IAAI,KAAKZ,mBAAmB,CAACa,IAAI,EAAE;MAC9C,OAAOb,mBAAmB,CAACa,IAAI;IACjC;IAEA,IAAIC,yBAAA,CAAAF,IAAI,EAAAG,IAAA,CAAJH,IAAI,EAAU,YAAY,CAAC,EAAE;MAC/B,OAAOZ,mBAAmB,CAACgB,UAAU;IACvC,CAAC,MAAM,IAAIF,yBAAA,CAAAF,IAAI,EAAAG,IAAA,CAAJH,IAAI,EAAU,qBAAqB,CAAC,EAAE;MAC/C,OAAOZ,mBAAmB,CAACiB,WAAW;IACxC;IACA,OAAOjB,mBAAmB,CAACkB,cAAc;EAC3C;;EAEA;AACF;E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/CpD,KAAK,CAACqD,KAAK,CAAC,CAAC;IAEb,MAAMC,WAAW,GAAGF,eAAe,IAAI5C,WAAW,CAAC,CAAC;IAEpD+C,MAAM,CAACC,QAAQ,CAACC,MAAM,CAAC,IAAI,CAACP,YAAY,CAAC,CAAC,GAAG,OAAO,GAAGI,WAAW,CAAC;EACrE;;EAEA;AACF;AACA;EACEI,MAAMA,CAAA,EAAiB;IACrB,OAAO3D,cAAc,CAAC;MACpBwB,GAAG,EAAE,IAAI,CAAC2B,YAAY,CAAC;IACzB,CAAC,CAAC,CAACF,IAAI,CAAEW,QAAQ,IAAK;MACpB;MACA3D,KAAK,CAACqD,KAAK,CAAC,CAAC;MACb,OAAOM,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAEA,eAAelD,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"Authenticate.js","names":["HTTP_METHODS","universalFetch","Cache","UnauthorizedException","INTERNAL_LOGIN_TYPE","loginType","loginPath","loginPasswordField","loginUsernameField","logoutPath","getBasePath","Authenticate","constructor","_defineProperty","_isBasic","authenticationType","type","JAAS","_includesInstanceProperty","call","PAC4J_FORM","PAC4J_BASIC","PAC4J_INDIRECT","isBasicAuthentication","requestLogin","url","method","GET","headers","Accept","initLogin","_Promise","resolve","catch","error","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","POST","data","addItem","btoa","then","removeItem","getLogoutUrl","redirectToLogout","postRedirectUrl","_context","clear","origin","window","location","redirectUrl","Function","bind","_startsWithInstanceProperty","assign","logout","response"],"sources":["../../src/modularui/Authenticate.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport Cache from \"../utils/browser/Cache\";\n\nimport { UnauthorizedException } from \"../exceptions\";\nimport {\n INTERNAL_LOGIN_TYPE,\n loginType,\n loginPath,\n loginPasswordField,\n loginUsernameField,\n logoutPath,\n getBasePath,\n} from \"../constants\";\n\n/**\n */\nclass Authenticate {\n _isBasic: boolean;\n\n /**\n */\n constructor() {\n this._isBasic = false;\n }\n\n /**\n */\n get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return INTERNAL_LOGIN_TYPE.JAAS;\n }\n\n if (type.includes(\"FormClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_FORM;\n } else if (type.includes(\"IndirectBasicClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;\n }\n return INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT;\n }\n\n /**\n */\n get isBasicAuthentication(): boolean {\n return (\n this._isBasic ||\n this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC\n );\n }\n\n /**\n */\n set isBasicAuthentication(isBasicAuthentication: boolean) {\n this._isBasic = isBasicAuthentication;\n }\n\n /**\n */\n requestLogin(): Promise<any> {\n return universalFetch({\n url: `${getBasePath()}/login`,\n method: HTTP_METHODS.GET,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n });\n }\n\n /**\n */\n initLogin(initLogin: boolean): Promise<any> {\n if (this.isBasicAuthentication || !initLogin) {\n return Promise.resolve(true);\n }\n\n return this.requestLogin().catch((error) => {\n // when an unauthorizedexception is received on a request to the login service,\n // this indicates a basic authorization scenario\n // in case of form based authentication other exceptions are thrown\n if (error instanceof UnauthorizedException) {\n this.isBasicAuthentication = true;\n }\n\n return Promise.resolve({});\n });\n }\n\n /**\n */\n login(username: string, password: string): Promise<any> {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return this.doFormLogin(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return this.doBasicAuthentication(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n // pac4j should handle this\n return Promise.resolve();\n default:\n return this.doJaasAuthentication(username, password);\n }\n }\n\n /**\n */\n getFormLoginUrl(): string {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return `${getBasePath()}${loginPath(\"DirectBasicAuthClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath(\"FormClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n //pac4j should handle this\n return \"\";\n default:\n return `${getBasePath()}/j_security_check`;\n }\n }\n\n /**\n */\n getFormLoginData(username: string, password: string): string {\n const encodedUsername = encodeURIComponent(username);\n const encodedPassword = encodeURIComponent(password);\n\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;\n case INTERNAL_LOGIN_TYPE.JAAS:\n return `j_username=${encodedUsername}&j_password=${encodedPassword}`;\n default:\n return \"\";\n }\n }\n\n /**\n */\n doFormLogin(username: string, password: string): Promise<any> {\n return universalFetch({\n url: this.getFormLoginUrl(),\n method: HTTP_METHODS.POST,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n data: this.getFormLoginData(username, password),\n });\n }\n\n /**\n */\n doBasicAuthentication(username: string, password: string): Promise<any> {\n Cache.addItem(\"basic\", btoa(`${username}:${password}`));\n return this.requestLogin();\n }\n\n /**\n */\n doJaasAuthentication(username: string, password: string): Promise<any> {\n return this.initLogin(true).then(() => {\n if (this.isBasicAuthentication) {\n Cache.removeItem(\"basic-ok\");\n return this.doBasicAuthentication(username, password).then(() => {\n Cache.addItem(\"basic-ok\", true);\n });\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n getLogoutUrl(): string {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return `${getBasePath()}/Logoff`;\n }\n\n return `${getBasePath()}${logoutPath()}`;\n }\n\n /**\n * Browser redirect to the logout url. (no xmlhttp)\n */\n redirectToLogout(postRedirectUrl: string = \"\"): void {\n Cache.clear();\n\n const origin = window.location.origin;\n const redirectUrl = postRedirectUrl?.startsWith(\"http\")\n ? postRedirectUrl\n : `${origin}${getBasePath()}`;\n\n window.location.assign(this.getLogoutUrl() + \"?url=\" + redirectUrl);\n }\n\n /**\n * Logout the user with xmlhttp\n */\n logout(): Promise<any> {\n return universalFetch({\n url: this.getLogoutUrl(),\n }).then((response) => {\n // clear cache because of cached contributions\n Cache.clear();\n return response;\n });\n }\n}\n\nexport default Authenticate;\n"],"mappings":";;;;AACA,SAASA,YAAY,QAAQ,wBAAwB;AAErD,OAAOC,cAAc,MAAM,+BAA+B;AAC1D,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SACEC,mBAAmB,EACnBC,SAAS,EACTC,SAAS,EACTC,kBAAkB,EAClBC,kBAAkB,EAClBC,UAAU,EACVC,WAAW,QACN,cAAc;;AAErB;AACA;AACA,MAAMC,YAAY,CAAC;EAGjB;AACF;EACEC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IACZ,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;;EAEA;AACF;EACE,IAAIC,kBAAkBA,CAAA,EAAsC;IAC1D,MAAMC,IAAI,GAAGX,SAAS,CAAC,CAAC;IAExB,IAAI,CAACW,IAAI,IAAIA,IAAI,KAAKZ,mBAAmB,CAACa,IAAI,EAAE;MAC9C,OAAOb,mBAAmB,CAACa,IAAI;IACjC;IAEA,IAAIC,yBAAA,CAAAF,IAAI,EAAAG,IAAA,CAAJH,IAAI,EAAU,YAAY,CAAC,EAAE;MAC/B,OAAOZ,mBAAmB,CAACgB,UAAU;IACvC,CAAC,MAAM,IAAIF,yBAAA,CAAAF,IAAI,EAAAG,IAAA,CAAJH,IAAI,EAAU,qBAAqB,CAAC,EAAE;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C,GAAGD,UAAU,CAAC,CAAC,EAAE;EAC1C;;EAEA;AACF;AACA;EACE4C,gBAAgBA,CAACC,eAAuB,GAAG,EAAE,EAAQ;IAAA,IAAAC,QAAA;IACnDrD,KAAK,CAACsD,KAAK,CAAC,CAAC;IAEb,MAAMC,MAAM,GAAGC,MAAM,CAACC,QAAQ,CAACF,MAAM;IACrC,MAAMG,WAAW,GAAG,EAAAL,QAAA,GAAAD,eAAe,qBAAAO,QAAA,CAAA1C,IAAA,CAAA2C,IAAA,CAAAC,2BAAA,CAAAR,QAAA,GAAAA,QAAA,KAAa,MAAM,CAAC,GACnDD,eAAe,GACf,GAAGG,MAAM,GAAG/C,WAAW,CAAC,CAAC,EAAE;IAE/BgD,MAAM,CAACC,QAAQ,CAACK,MAAM,CAAC,IAAI,CAACZ,YAAY,CAAC,CAAC,GAAG,OAAO,GAAGQ,WAAW,CAAC;EACrE;;EAEA;AACF;AACA;EACEK,MAAMA,CAAA,EAAiB;IACrB,OAAOhE,cAAc,CAAC;MACpBwB,GAAG,EAAE,IAAI,CAAC2B,YAAY,CAAC;IACzB,CAAC,CAAC,CAACF,IAAI,CAAEgB,QAAQ,IAAK;MACpB;MACAhE,KAAK,CAACsD,KAAK,CAAC,CAAC;MACb,OAAOU,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAEA,eAAevD,YAAY","ignoreList":[]}
@@ -45,8 +45,7 @@ exports.useLogin = useLogin;
45
45
  const useLogout = () => {
46
46
  const dispatch = (0, _reactRedux.useDispatch)();
47
47
  const application = (0, _reactRedux.useSelector)(_ModularUISelectors.getApplication);
48
- const LOGOUT_PATH = (0, _constants.logoutPath)();
49
- const BASE_PATH = (0, _constants.getBasePathServer)();
48
+ const BASE_PATH = (0, _constants.getBasePath)();
50
49
  const authenticate = new _modularui.Authenticate();
51
50
  const isAuthenticated = application?.isLoggedIn ?? false;
52
51
  return {
@@ -58,7 +57,7 @@ const useLogout = () => {
58
57
  authenticate.redirectToLogout();
59
58
  } else if (_Cache.default.getItem("isRedirectLogin")) {
60
59
  const origin = window.location.origin;
61
- const url = `${origin}${BASE_PATH}/logout?url=${origin}${BASE_PATH}${LOGOUT_PATH}`;
60
+ const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;
62
61
  _Cache.default.setItem("isRedirectLogin", false);
63
62
  window.location.assign(url);
64
63
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_ModularUISelectors","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","useLogin","Cache","setItem","dispatch","useDispatch","application","useSelector","getApplication","auth","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","LOGOUT_PATH","logoutPath","BASE_PATH","authenticate","Authenticate","logout","type","INTERNAL_LOGIN_TYPE","PAC4J_INDIRECT","redirectToLogout","origin","url","logoutUrl","getLogoutUrl"],"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 getBasePathServer,\n INTERNAL_LOGIN_TYPE,\n logoutPath,\n} from \"../constants\";\nimport { IllegalStateException } from \"../exceptions\";\nimport { Authenticate } from \"../modularui\";\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 = useSelector(getApplication);\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 LOGOUT_PATH = logoutPath();\n const BASE_PATH = getBasePathServer();\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 = `${origin}${BASE_PATH}/logout?url=${origin}${BASE_PATH}${LOGOUT_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n logoutUrl: authenticate.get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AAQ,CAACC,MAAM,CAACe,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAOzC,QAAQ,CAAC,IAAAmC,eAAM,EAAC,CAAC,CAAC;MAC3B;IACF,CAAC;IACDO,SAAS,EAAET,YAAY,CAACU,YAAY,CAAC;EACvC,CAAC;AACH,CAAC;AAACf,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"useAuthentication.js","names":["_reactRedux","require","_ModularUISelectors","_actions","_Cache","_interopRequireDefault","_constants","_exceptions","_modularui","useLogin","Cache","setItem","dispatch","useDispatch","application","useSelector","getApplication","auth","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","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\";\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 = useSelector(getApplication);\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,IAAA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AAC,CAAC;MAC3B;IACF,CAAC;IACDQ,SAAS,EAAEV,YAAY,CAACS,YAAY,CAAC;EACvC,CAAC;AACH,CAAC;AAACb,OAAA,CAAAC,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -181,13 +181,13 @@ class ListDetailModel extends _DetailModel.default {
181
181
  var _context2;
182
182
  const givenAnswersData = this.data.resultSection.givenAnswers;
183
183
  const givenAnswersContributions = this.contributions.resultSection.givenAnswers;
184
- const filteredContributions = {
184
+ const filteredContributions = givenAnswersContributions.children ? {
185
185
  ...givenAnswersContributions,
186
186
  children: (0, _filter.default)(_context2 = givenAnswersContributions.children).call(_context2, child => {
187
187
  const childKey = (0, _keys.default)(child)[0];
188
188
  return childKey in givenAnswersData;
189
189
  })
190
- };
190
+ } : givenAnswersContributions;
191
191
  const givenAnswers = (0, _createAttribute.default)("givenAnswers", {
192
192
  key: "givenAnswers",
193
193
  dynamicschema: this.data.dynamicschema,
@@ -1 +1 @@
1
- {"version":3,"file":"ListDetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_DetailModel","_ContentConfiguration","_AttributeSetModel","_createAttribute","_CompositeAttributeModel","ListDetailModel","DetailModel","constructor","modularUIResponse","_defineProperty2","default","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","getInitialChildModelLinks","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","givenAnswers","setChildModels","models","errors","_attributeCollection","type","modelName","isApplicableModel","data","resourcetype","toLowerCase","_endsWith","call","_listitem","actionCollection","panelLinks","contentConfiguration","configuration","introtext","_content","text","message","Array","isArray","texts","has","setResults","setGivenAnswers","resultsData","resultSection","resultsContributions","_context","children","_filter","child","childKey","_keys","createAttribute","key","dynamicschema","CompositeAttributeModel","isResult","indicateContentConfiguration","_results","_context2","givenAnswersData","givenAnswersContributions","filteredContributions","_givenAnswers","hasEventData","eventdata","addAttributes","eventData","eventContributions","_eventdata","AttributeSetModel","modelOptions","forEach","eventDataContribution","eventDataData","i","exports"],"sources":["../../../src/models/list/ListDetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {},\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n\n if (this.results) {\n this.results.setChildModels(models, errors);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models, errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ListDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n let resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n resourcetype = resourcetype.toLowerCase();\n\n return (\n resourcetype.endsWith(\"listdetail\") ||\n resourcetype.endsWith(\"listpaneldetail\") ||\n resourcetype.endsWith(\"datastorepaneldetail\")\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const resultsData = this.data.resultSection.results;\n const resultsContributions = this.contributions.resultSection.results;\n if (resultsContributions.type === \"composite\") {\n resultsContributions.children = resultsContributions.children.filter(\n (child) => {\n const childKey = Object.keys(child)[0];\n return childKey in resultsData;\n },\n );\n }\n\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n resultsContributions,\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions,\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(\n key,\n eventData,\n eventContributions,\n this.modelOptions,\n ),\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,qBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,kBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEA,IAAAM,gBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,wBAAA,GAAAL,sBAAA,CAAAF,OAAA;AASA;AACA;AACA;AACe,MAAMQ,eAAe,SAASC,oBAAW,CAAC;EAOvD;AACF;AACA;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzB,IAAI,CAACC,iBAAiB,GAAG,IAAIC,yBAAgB,CAAC,CAAC;IAE/C,IAAI,CAACC,qBAAqB,GAAG,IAAIC,6BAAoB,CACnD,IAAI,CAACC,aAAa,GAAG,IAAI,CAACA,aAAa,CAACC,OAAO,GAAG,CAAC,CACrD,CAAC;IAED,IAAI,CAACC,gBAAgB,CAAC,CAAC;IACvB,I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MAEpB,IAAI,CAACnE,aAAa,CAAC+D,SAAS,CAACO,OAAO,CAAEC,qBAAqB,IAAK;QAC9D,MAAM,CAACpB,GAAG,CAAC,GAAG,IAAAF,KAAA,CAAAtD,OAAA,EAAY4E,qBAAqB,CAAC;QAChD,IAAIpB,GAAG,IAAI,IAAI,CAAC9B,IAAI,CAAC0C,SAAS,EAAE;UAC9B,IAAI5B,KAAK,CAACC,OAAO,CAAC,IAAI,CAACf,IAAI,CAAC0C,SAAS,CAACZ,GAAG,CAAC,CAAC,EAAE;YAC3C,IAAI,CAAC9B,IAAI,CAAC0C,SAAS,CAACZ,GAAG,CAAC,CAACmB,OAAO,CAAC,CAACE,aAAa,EAAEC,CAAC,KAAK;cACrD,IAAI,CAACT,aAAa,CAChB,GAAGb,GAAG,IAAIsB,CAAC,GAAG,CAAC,EAAE,EACjB;gBACE,GAAGD,aAAa;gBAChBpB,aAAa,EAAE,IAAI,CAAC/B,IAAI,CAAC+B;cAC3B,CAAC,EACDmB,qBAAqB,CAACpB,GAAG,CAC3B,CAAC;YACH,CAAC,CAAC;UACJ,CAAC,MAAM;YACL,IAAI,CAACa,aAAa,CAChBb,GAAG,EACH;cACE,GAAG,IAAI,CAAC9B,IAAI,CAAC0C,SAAS,CAACZ,GAAG,CAAC;cAC3BC,aAAa,EAAE,IAAI,CAAC/B,IAAI,CAAC+B;YAC3B,CAAC,EACDmB,qBAAqB,CAACpB,GAAG,CAC3B,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;EACE,IAAIY,SAASA,CAAA,EAA6B;IACxC,OAAO,IAAI,CAACI,UAAU;EACxB;AACF;AAACO,OAAA,CAAA/E,OAAA,GAAAL,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"ListDetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_DetailModel","_ContentConfiguration","_AttributeSetModel","_createAttribute","_CompositeAttributeModel","ListDetailModel","DetailModel","constructor","modularUIResponse","_defineProperty2","default","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","getInitialChildModelLinks","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","givenAnswers","setChildModels","models","errors","_attributeCollection","type","modelName","isApplicableModel","data","resourcetype","toLowerCase","_endsWith","call","_listitem","actionCollection","panelLinks","contentConfiguration","configuration","introtext","_content","text","message","Array","isArray","texts","has","setResults","setGivenAnswers","resultsData","resultSection","resultsContributions","_context","children","_filter","child","childKey","_keys","createAttribute","key","dynamicschema","CompositeAttributeModel","isResult","indicateContentConfiguration","_results","_context2","givenAnswersData","givenAnswersContributions","filteredContributions","_givenAnswers","hasEventData","eventdata","addAttributes","eventData","eventContributions","_eventdata","AttributeSetModel","modelOptions","forEach","eventDataContribution","eventDataData","i","exports"],"sources":["../../../src/models/list/ListDetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {},\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n\n if (this.results) {\n this.results.setChildModels(models, errors);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models, errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ListDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n let resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n resourcetype = resourcetype.toLowerCase();\n\n return (\n resourcetype.endsWith(\"listdetail\") ||\n resourcetype.endsWith(\"listpaneldetail\") ||\n resourcetype.endsWith(\"datastorepaneldetail\")\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const resultsData = this.data.resultSection.results;\n const resultsContributions = this.contributions.resultSection.results;\n if (resultsContributions.type === \"composite\") {\n resultsContributions.children = resultsContributions.children.filter(\n (child) => {\n const childKey = Object.keys(child)[0];\n return childKey in resultsData;\n },\n );\n }\n\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n resultsContributions,\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = givenAnswersContributions.children\n ? {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n }\n : givenAnswersContributions;\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions,\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(\n key,\n eventData,\n eventContributions,\n this.modelOptions,\n ),\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,qBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,kBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEA,IAAAM,gBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,wBAAA,GAAAL,sBAAA,CAAAF,OAAA;AASA;AACA;AACA;AACe,MAAMQ,eAAe,SA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C,MAAM;YACL,IAAI,CAACa,aAAa,CAChBb,GAAG,EACH;cACE,GAAG,IAAI,CAAC9B,IAAI,CAAC0C,SAAS,CAACZ,GAAG,CAAC;cAC3BC,aAAa,EAAE,IAAI,CAAC/B,IAAI,CAAC+B;YAC3B,CAAC,EACDmB,qBAAqB,CAACpB,GAAG,CAC3B,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;EACE,IAAIY,SAASA,CAAA,EAA6B;IACxC,OAAO,IAAI,CAACI,UAAU;EACxB;AACF;AAACO,OAAA,CAAA/E,OAAA,GAAAL,eAAA","ignoreList":[]}
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
9
9
  var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
10
+ var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
10
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
11
12
  var _Constants = require("../constants/Constants");
12
13
  var _universalFetch = _interopRequireDefault(require("../utils/fetch/universalFetch"));
@@ -176,9 +177,11 @@ class Authenticate {
176
177
  /**
177
178
  * Browser redirect to the logout url. (no xmlhttp)
178
179
  */
179
- redirectToLogout(postRedirectUrl) {
180
+ redirectToLogout(postRedirectUrl = "") {
181
+ var _context;
180
182
  _Cache.default.clear();
181
- const redirectUrl = postRedirectUrl || (0, _constants.getBasePath)();
183
+ const origin = window.location.origin;
184
+ const redirectUrl = ((_context = postRedirectUrl) == null ? void 0 : Function.call.bind((0, _startsWith.default)(_context), _context))?.("http") ? postRedirectUrl : `${origin}${(0, _constants.getBasePath)()}`;
182
185
  window.location.assign(this.getLogoutUrl() + "?url=" + redirectUrl);
183
186
  }
184
187
 
@@ -1 +1 @@
1
- {"version":3,"file":"Authenticate.js","names":["_Constants","require","_universalFetch","_interopRequireDefault","_Cache","_exceptions","_constants","Authenticate","constructor","_defineProperty2","default","_isBasic","authenticationType","type","loginType","INTERNAL_LOGIN_TYPE","JAAS","_includes","call","PAC4J_FORM","PAC4J_BASIC","PAC4J_INDIRECT","isBasicAuthentication","requestLogin","universalFetch","url","getBasePath","method","HTTP_METHODS","GET","headers","Accept","initLogin","_promise","resolve","catch","error","UnauthorizedException","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","loginPath","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","loginUsernameField","loginPasswordField","POST","data","Cache","addItem","btoa","then","removeItem","getLogoutUrl","logoutPath","redirectToLogout","postRedirectUrl","clear","redirectUrl","window","location","assign","logout","response","_default","exports"],"sources":["../../src/modularui/Authenticate.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport Cache from \"../utils/browser/Cache\";\n\nimport { UnauthorizedException } from \"../exceptions\";\nimport {\n INTERNAL_LOGIN_TYPE,\n loginType,\n loginPath,\n loginPasswordField,\n loginUsernameField,\n logoutPath,\n getBasePath,\n} from \"../constants\";\n\n/**\n */\nclass Authenticate {\n _isBasic: boolean;\n\n /**\n */\n constructor() {\n this._isBasic = false;\n }\n\n /**\n */\n get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return INTERNAL_LOGIN_TYPE.JAAS;\n }\n\n if (type.includes(\"FormClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_FORM;\n } else if (type.includes(\"IndirectBasicClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;\n }\n return INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT;\n }\n\n /**\n */\n get isBasicAuthentication(): boolean {\n return (\n this._isBasic ||\n this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC\n );\n }\n\n /**\n */\n set isBasicAuthentication(isBasicAuthentication: boolean) {\n this._isBasic = isBasicAuthentication;\n }\n\n /**\n */\n requestLogin(): Promise<any> {\n return universalFetch({\n url: `${getBasePath()}/login`,\n method: HTTP_METHODS.GET,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n });\n }\n\n /**\n */\n initLogin(initLogin: boolean): Promise<any> {\n if (this.isBasicAuthentication || !initLogin) {\n return Promise.resolve(true);\n }\n\n return this.requestLogin().catch((error) => {\n // when an unauthorizedexception is received on a request to the login service,\n // this indicates a basic authorization scenario\n // in case of form based authentication other exceptions are thrown\n if (error instanceof UnauthorizedException) {\n this.isBasicAuthentication = true;\n }\n\n return Promise.resolve({});\n });\n }\n\n /**\n */\n login(username: string, password: string): Promise<any> {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return this.doFormLogin(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return this.doBasicAuthentication(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n // pac4j should handle this\n return Promise.resolve();\n default:\n return this.doJaasAuthentication(username, password);\n }\n }\n\n /**\n */\n getFormLoginUrl(): string {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return `${getBasePath()}${loginPath(\"DirectBasicAuthClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath(\"FormClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n //pac4j should handle this\n return \"\";\n default:\n return `${getBasePath()}/j_security_check`;\n }\n }\n\n /**\n */\n getFormLoginData(username: string, password: string): string {\n const encodedUsername = encodeURIComponent(username);\n const encodedPassword = encodeURIComponent(password);\n\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;\n case INTERNAL_LOGIN_TYPE.JAAS:\n return `j_username=${encodedUsername}&j_password=${encodedPassword}`;\n default:\n return \"\";\n }\n }\n\n /**\n */\n doFormLogin(username: string, password: string): Promise<any> {\n return universalFetch({\n url: this.getFormLoginUrl(),\n method: HTTP_METHODS.POST,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n data: this.getFormLoginData(username, password),\n });\n }\n\n /**\n */\n doBasicAuthentication(username: string, password: string): Promise<any> {\n Cache.addItem(\"basic\", btoa(`${username}:${password}`));\n return this.requestLogin();\n }\n\n /**\n */\n doJaasAuthentication(username: string, password: string): Promise<any> {\n return this.initLogin(true).then(() => {\n if (this.isBasicAuthentication) {\n Cache.removeItem(\"basic-ok\");\n return this.doBasicAuthentication(username, password).then(() => {\n Cache.addItem(\"basic-ok\", true);\n });\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n getLogoutUrl(): string {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return `${getBasePath()}/Logoff`;\n }\n\n return `${getBasePath()}${logoutPath()}`;\n }\n\n /**\n * Browser redirect to the logout url. (no xmlhttp)\n */\n redirectToLogout(postRedirectUrl?: string): void {\n Cache.clear();\n\n const redirectUrl = postRedirectUrl || getBasePath();\n\n window.location.assign(this.getLogoutUrl() + \"?url=\" + redirectUrl);\n }\n\n /**\n * Logout the user with xmlhttp\n */\n logout(): Promise<any> {\n return universalFetch({\n url: this.getLogoutUrl(),\n }).then((response) => {\n // clear cache because of cached contributions\n Cache.clear();\n return response;\n });\n }\n}\n\nexport default Authenticate;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,WAAA,GAA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AEY,QAAQ,IAAK;MACpB;MACAf,cAAK,CAACS,KAAK,CAAC,CAAC;MACb,OAAOM,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA7D,OAAA,GAEcH,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"Authenticate.js","names":["_Constants","require","_universalFetch","_interopRequireDefault","_Cache","_exceptions","_constants","Authenticate","constructor","_defineProperty2","default","_isBasic","authenticationType","type","loginType","INTERNAL_LOGIN_TYPE","JAAS","_includes","call","PAC4J_FORM","PAC4J_BASIC","PAC4J_INDIRECT","isBasicAuthentication","requestLogin","universalFetch","url","getBasePath","method","HTTP_METHODS","GET","headers","Accept","initLogin","_promise","resolve","catch","error","UnauthorizedException","login","username","password","doFormLogin","doBasicAuthentication","doJaasAuthentication","getFormLoginUrl","loginPath","getFormLoginData","encodedUsername","encodeURIComponent","encodedPassword","loginUsernameField","loginPasswordField","POST","data","Cache","addItem","btoa","then","removeItem","getLogoutUrl","logoutPath","redirectToLogout","postRedirectUrl","_context","clear","origin","window","location","redirectUrl","Function","bind","_startsWith","assign","logout","response","_default","exports"],"sources":["../../src/modularui/Authenticate.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport Cache from \"../utils/browser/Cache\";\n\nimport { UnauthorizedException } from \"../exceptions\";\nimport {\n INTERNAL_LOGIN_TYPE,\n loginType,\n loginPath,\n loginPasswordField,\n loginUsernameField,\n logoutPath,\n getBasePath,\n} from \"../constants\";\n\n/**\n */\nclass Authenticate {\n _isBasic: boolean;\n\n /**\n */\n constructor() {\n this._isBasic = false;\n }\n\n /**\n */\n get authenticationType(): $Keys<typeof INTERNAL_LOGIN_TYPE> {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return INTERNAL_LOGIN_TYPE.JAAS;\n }\n\n if (type.includes(\"FormClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_FORM;\n } else if (type.includes(\"IndirectBasicClient\")) {\n return INTERNAL_LOGIN_TYPE.PAC4J_BASIC;\n }\n return INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT;\n }\n\n /**\n */\n get isBasicAuthentication(): boolean {\n return (\n this._isBasic ||\n this.authenticationType === INTERNAL_LOGIN_TYPE.PAC4J_BASIC\n );\n }\n\n /**\n */\n set isBasicAuthentication(isBasicAuthentication: boolean) {\n this._isBasic = isBasicAuthentication;\n }\n\n /**\n */\n requestLogin(): Promise<any> {\n return universalFetch({\n url: `${getBasePath()}/login`,\n method: HTTP_METHODS.GET,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n });\n }\n\n /**\n */\n initLogin(initLogin: boolean): Promise<any> {\n if (this.isBasicAuthentication || !initLogin) {\n return Promise.resolve(true);\n }\n\n return this.requestLogin().catch((error) => {\n // when an unauthorizedexception is received on a request to the login service,\n // this indicates a basic authorization scenario\n // in case of form based authentication other exceptions are thrown\n if (error instanceof UnauthorizedException) {\n this.isBasicAuthentication = true;\n }\n\n return Promise.resolve({});\n });\n }\n\n /**\n */\n login(username: string, password: string): Promise<any> {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return this.doFormLogin(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return this.doBasicAuthentication(username, password);\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n // pac4j should handle this\n return Promise.resolve();\n default:\n return this.doJaasAuthentication(username, password);\n }\n }\n\n /**\n */\n getFormLoginUrl(): string {\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n return `${getBasePath()}${loginPath(\"DirectBasicAuthClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${getBasePath()}${loginPath(\"FormClient\")}`;\n case INTERNAL_LOGIN_TYPE.PAC4J_INDIRECT:\n //pac4j should handle this\n return \"\";\n default:\n return `${getBasePath()}/j_security_check`;\n }\n }\n\n /**\n */\n getFormLoginData(username: string, password: string): string {\n const encodedUsername = encodeURIComponent(username);\n const encodedPassword = encodeURIComponent(password);\n\n switch (this.authenticationType) {\n case INTERNAL_LOGIN_TYPE.PAC4J_BASIC:\n case INTERNAL_LOGIN_TYPE.PAC4J_FORM:\n return `${loginUsernameField()}=${encodedUsername}&${loginPasswordField()}=${encodedPassword}`;\n case INTERNAL_LOGIN_TYPE.JAAS:\n return `j_username=${encodedUsername}&j_password=${encodedPassword}`;\n default:\n return \"\";\n }\n }\n\n /**\n */\n doFormLogin(username: string, password: string): Promise<any> {\n return universalFetch({\n url: this.getFormLoginUrl(),\n method: HTTP_METHODS.POST,\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/x-www-form-urlencoded\",\n },\n data: this.getFormLoginData(username, password),\n });\n }\n\n /**\n */\n doBasicAuthentication(username: string, password: string): Promise<any> {\n Cache.addItem(\"basic\", btoa(`${username}:${password}`));\n return this.requestLogin();\n }\n\n /**\n */\n doJaasAuthentication(username: string, password: string): Promise<any> {\n return this.initLogin(true).then(() => {\n if (this.isBasicAuthentication) {\n Cache.removeItem(\"basic-ok\");\n return this.doBasicAuthentication(username, password).then(() => {\n Cache.addItem(\"basic-ok\", true);\n });\n }\n return this.doFormLogin(username, password);\n });\n }\n\n /**\n */\n getLogoutUrl(): string {\n const type = loginType();\n\n if (!type || type === INTERNAL_LOGIN_TYPE.JAAS) {\n return `${getBasePath()}/Logoff`;\n }\n\n return `${getBasePath()}${logoutPath()}`;\n }\n\n /**\n * Browser redirect to the logout url. (no xmlhttp)\n */\n redirectToLogout(postRedirectUrl: string = \"\"): void {\n Cache.clear();\n\n const origin = window.location.origin;\n const redirectUrl = postRedirectUrl?.startsWith(\"http\")\n ? postRedirectUrl\n : `${origin}${getBasePath()}`;\n\n window.location.assign(this.getLogoutUrl() + \"?url=\" + redirectUrl);\n }\n\n /**\n * Logout the user with xmlhttp\n */\n logout(): Promise<any> {\n return universalFetch({\n url: this.getLogoutUrl(),\n }).then((response) => {\n // clear cache because of cached contributions\n Cache.clear();\n return response;\n });\n }\n}\n\nexport default Authenticate;\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,MAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAUA;AACA;AACA,MAAMM,YAAY,CAAC;EAGjB;AACF;EACEC,WAAWA,CAAA,EAAG;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACZ,IAAI,CAACC,QAAQ,GAAG,KAAK;EACvB;;EAEA;AACF;EACE,IAAIC,kBAAkBA,CAAA,EAAsC;IAC1D,MAAMC,IAAI,GAAG,IAAAC,oBAAS,EAAC,CAAC;IAExB,IAAI,CAACD,IAAI,IAAIA,IAAI,KAAKE,8BAAmB,CAACC,IAAI,EAAE;MAC9C,OAAOD,8BAAmB,CAACC,IAAI;IACjC;IAEA,IAAI,IAAAC,SAAA,CAAAP,OAAA,EAAAG,IAAI,EAAAK,IAAA,CAAJL,IAAI,EAAU,YAAY,CAAC,EAAE;MAC/B,OAAOE,8BAAmB,CAACI,UAAU;IACvC,CAAC,MAAM,IAAI,IAAAF,SAAA,CAAAP,OAAA,EAAAG,IAAI,EAAAK,IAAA,CAAJL,IAAI,EAAU,qBAAqB,CAAC,EAAE;MAC/C,OAAOE,8BAAmB,CAACK,WAAW;IACxC;IACA,OAAOL,8BAAmB,CAACM,cAAc;EAC3C;;EAEA;AACF;EACE,IAAIC,qBAAqBA,CAAA,EAAY;IACnC,OACE,IAAI,CAACX,QAAQ,IACb,IAAI,CAACC,kBAAkB,KAAKG,8BAAmB,CAACK,WAAW;EAE/D;;EAEA;AACF;EACE,IAAIE,qBAAqBA,CAACA,qBAA8B,EAAE;IAC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AEb,MAAMC,MAAM,GAAGC,MAAM,CAACC,QAAQ,CAACF,MAAM;IACrC,MAAMG,WAAW,GAAG,EAAAL,QAAA,GAAAD,eAAe,qBAAAO,QAAA,CAAAnD,IAAA,CAAAoD,IAAA,KAAAC,WAAA,CAAA7D,OAAA,EAAAqD,QAAA,GAAAA,QAAA,KAAa,MAAM,CAAC,GACnDD,eAAe,GACf,GAAGG,MAAM,GAAG,IAAAvC,sBAAW,EAAC,CAAC,EAAE;IAE/BwC,MAAM,CAACC,QAAQ,CAACK,MAAM,CAAC,IAAI,CAACb,YAAY,CAAC,CAAC,GAAG,OAAO,GAAGS,WAAW,CAAC;EACrE;;EAEA;AACF;AACA;EACEK,MAAMA,CAAA,EAAiB;IACrB,OAAO,IAAAjD,uBAAc,EAAC;MACpBC,GAAG,EAAE,IAAI,CAACkC,YAAY,CAAC;IACzB,CAAC,CAAC,CAACF,IAAI,CAAEiB,QAAQ,IAAK;MACpB;MACApB,cAAK,CAACU,KAAK,CAAC,CAAC;MACb,OAAOU,QAAQ;IACjB,CAAC,CAAC;EACJ;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlE,OAAA,GAEcH,YAAY","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.63.9",
3
+ "version": "1.63.11",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "https://support.beinformed.com",
@@ -7,9 +7,9 @@ import { login, logout, resetAuthErrors } from "../redux/actions";
7
7
  import Cache from "../utils/browser/Cache";
8
8
  import {
9
9
  DEFAULT_AUTHENTICATION_TYPE,
10
+ getBasePath,
10
11
  getBasePathServer,
11
12
  INTERNAL_LOGIN_TYPE,
12
- logoutPath,
13
13
  } from "../constants";
14
14
  import { IllegalStateException } from "../exceptions";
15
15
  import { Authenticate } from "../modularui";
@@ -79,8 +79,7 @@ export const useLogout = (): LogoutHook => {
79
79
  const dispatch = useDispatch();
80
80
  const application = useSelector(getApplication);
81
81
 
82
- const LOGOUT_PATH = logoutPath();
83
- const BASE_PATH = getBasePathServer();
82
+ const BASE_PATH = getBasePath();
84
83
 
85
84
  const authenticate = new Authenticate();
86
85
 
@@ -96,7 +95,7 @@ export const useLogout = (): LogoutHook => {
96
95
  authenticate.redirectToLogout();
97
96
  } else if (Cache.getItem("isRedirectLogin")) {
98
97
  const origin = window.location.origin;
99
- const url = `${origin}${BASE_PATH}/logout?url=${origin}${BASE_PATH}${LOGOUT_PATH}`;
98
+ const url = `${authenticate.getLogoutUrl()}?url=${origin}${BASE_PATH}`;
100
99
  Cache.setItem("isRedirectLogin", false);
101
100
  window.location.assign(url);
102
101
  } else {
@@ -219,13 +219,15 @@ export default class ListDetailModel extends DetailModel {
219
219
  const givenAnswersContributions =
220
220
  this.contributions.resultSection.givenAnswers;
221
221
 
222
- const filteredContributions = {
223
- ...givenAnswersContributions,
224
- children: givenAnswersContributions.children.filter((child) => {
225
- const childKey = Object.keys(child)[0];
226
- return childKey in givenAnswersData;
227
- }),
228
- };
222
+ const filteredContributions = givenAnswersContributions.children
223
+ ? {
224
+ ...givenAnswersContributions,
225
+ children: givenAnswersContributions.children.filter((child) => {
226
+ const childKey = Object.keys(child)[0];
227
+ return childKey in givenAnswersData;
228
+ }),
229
+ }
230
+ : givenAnswersContributions;
229
231
 
230
232
  const givenAnswers = createAttribute(
231
233
  "givenAnswers",
@@ -189,10 +189,13 @@ class Authenticate {
189
189
  /**
190
190
  * Browser redirect to the logout url. (no xmlhttp)
191
191
  */
192
- redirectToLogout(postRedirectUrl?: string): void {
192
+ redirectToLogout(postRedirectUrl: string = ""): void {
193
193
  Cache.clear();
194
194
 
195
- const redirectUrl = postRedirectUrl || getBasePath();
195
+ const origin = window.location.origin;
196
+ const redirectUrl = postRedirectUrl?.startsWith("http")
197
+ ? postRedirectUrl
198
+ : `${origin}${getBasePath()}`;
196
199
 
197
200
  window.location.assign(this.getLogoutUrl() + "?url=" + redirectUrl);
198
201
  }