@beinformed/ui 1.20.1 → 1.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/esm/constants/Constants.js +0 -15
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/constants/Settings.js +6 -0
  5. package/esm/constants/Settings.js.map +1 -1
  6. package/esm/hooks/useAuthentication.js +41 -5
  7. package/esm/hooks/useAuthentication.js.map +1 -1
  8. package/esm/i18n/translations/beinformed_error_messages_en.nl.js +3 -2
  9. package/esm/i18n/translations/beinformed_error_messages_en.nl.js.map +1 -1
  10. package/esm/i18n/translations/beinformed_error_messages_nl.nl.js +4 -3
  11. package/esm/i18n/translations/beinformed_error_messages_nl.nl.js.map +1 -1
  12. package/esm/models/application/ApplicationModel.js +6 -1
  13. package/esm/models/application/ApplicationModel.js.map +1 -1
  14. package/esm/redux/_modularui/actions.js +1 -1
  15. package/esm/redux/_modularui/actions.js.map +1 -1
  16. package/esm/redux/actions/Authorization.js +5 -9
  17. package/esm/redux/actions/Authorization.js.map +1 -1
  18. package/esm/redux/actions/Error.js +3 -1
  19. package/esm/redux/actions/Error.js.map +1 -1
  20. package/esm/redux/actions/SignIn.js +7 -0
  21. package/esm/redux/actions/SignIn.js.map +1 -1
  22. package/esm/redux/types.js.map +1 -1
  23. package/lib/constants/Constants.js +2 -20
  24. package/lib/constants/Constants.js.flow +0 -15
  25. package/lib/constants/Constants.js.map +1 -1
  26. package/lib/constants/Settings.js +6 -0
  27. package/lib/constants/Settings.js.flow +9 -0
  28. package/lib/constants/Settings.js.map +1 -1
  29. package/lib/hooks/useAuthentication.js +49 -5
  30. package/lib/hooks/useAuthentication.js.flow +42 -3
  31. package/lib/hooks/useAuthentication.js.map +1 -1
  32. package/lib/i18n/translations/beinformed_error_messages_en.nl.js +3 -2
  33. package/lib/i18n/translations/beinformed_error_messages_en.nl.js.flow +3 -2
  34. package/lib/i18n/translations/beinformed_error_messages_en.nl.js.map +1 -1
  35. package/lib/i18n/translations/beinformed_error_messages_nl.nl.js +4 -3
  36. package/lib/i18n/translations/beinformed_error_messages_nl.nl.js.flow +4 -3
  37. package/lib/i18n/translations/beinformed_error_messages_nl.nl.js.map +1 -1
  38. package/lib/models/application/ApplicationModel.js +7 -1
  39. package/lib/models/application/ApplicationModel.js.flow +7 -1
  40. package/lib/models/application/ApplicationModel.js.map +1 -1
  41. package/lib/redux/_modularui/actions.js +1 -1
  42. package/lib/redux/_modularui/actions.js.flow +1 -4
  43. package/lib/redux/_modularui/actions.js.map +1 -1
  44. package/lib/redux/actions/Authorization.js +7 -12
  45. package/lib/redux/actions/Authorization.js.flow +4 -16
  46. package/lib/redux/actions/Authorization.js.map +1 -1
  47. package/lib/redux/actions/Error.js +4 -1
  48. package/lib/redux/actions/Error.js.flow +3 -1
  49. package/lib/redux/actions/Error.js.map +1 -1
  50. package/lib/redux/actions/SignIn.js +12 -2
  51. package/lib/redux/actions/SignIn.js.flow +11 -2
  52. package/lib/redux/actions/SignIn.js.map +1 -1
  53. package/lib/redux/actions/__tests__/Authorization.spec.js.flow +4 -18
  54. package/lib/redux/types.js.flow +2 -2
  55. package/lib/redux/types.js.map +1 -1
  56. package/package.json +18 -18
  57. package/src/constants/Constants.js +0 -15
  58. package/src/constants/Settings.js +9 -0
  59. package/src/hooks/useAuthentication.js +42 -3
  60. package/src/i18n/translations/beinformed_error_messages_en.nl.js +3 -2
  61. package/src/i18n/translations/beinformed_error_messages_nl.nl.js +4 -3
  62. package/src/models/application/ApplicationModel.js +7 -1
  63. package/src/redux/_modularui/actions.js +1 -4
  64. package/src/redux/actions/Authorization.js +4 -16
  65. package/src/redux/actions/Error.js +3 -1
  66. package/src/redux/actions/SignIn.js +11 -2
  67. package/src/redux/actions/__tests__/Authorization.spec.js +4 -18
  68. package/src/redux/types.js +2 -2
@@ -9,7 +9,7 @@ import { push } from "../_router/actions";
9
9
  import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
10
10
 
11
11
  import type {
12
- LoginFailedAction,
12
+ SendAuthenticationErrorAction,
13
13
  ResetAuthErrorsAction,
14
14
  LoginSuccessAction,
15
15
  ThunkAction,
@@ -18,7 +18,16 @@ import type {
18
18
  /**
19
19
  * Send login failed action
20
20
  */
21
- export const loginFailed = (errorMessage: string): LoginFailedAction => ({
21
+ export const loginFailed = (
22
+ errorMessage: string
23
+ ): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);
24
+
25
+ /**
26
+ * Send authentication error action
27
+ */
28
+ export const sendAuthenticationError = (
29
+ errorMessage: string
30
+ ): SendAuthenticationErrorAction => ({
22
31
  type: "AUTHENTICATION_ERROR",
23
32
  payload: errorMessage,
24
33
  });
@@ -1 +1 @@
1
- {"version":3,"file":"SignIn.js","names":["loginFailed","errorMessage","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","push","CHANGEPASSWORD_PATH","login","username","password","startProgress","Authenticate","then","reloadApplication","Cache","addItem","finishProgress","catch","error","id","dispatchedReloadApplication","resolve"],"sources":["../../../src/redux/actions/SignIn.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport { reloadApplication } from \"./Application\";\n\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\nimport { push } from \"../_router/actions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n LoginFailedAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (errorMessage: string): LoginFailedAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n })\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(loginSuccess());\n\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n return dispatch(changePassword());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(finishProgress());\n });\n };\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AASA;AACA;AACA;AACO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CAACC,YAAD;EAAA,OAA8C;IACvEC,IAAI,EAAE,sBADiE;IAEvEC,OAAO,EAAEF;EAF8D,CAA9C;AAAA,CAApB;AAKP;AACA;AACA;;;;;AACO,IAAMG,eAAe,GAAG,SAAlBA,eAAkB;EAAA,OAA8B;IAC3DF,IAAI,EAAE;EADqD,CAA9B;AAAA,CAAxB;AAIP;AACA;AACA;;;;;AACO,IAAMG,YAAY,GAAG,SAAfA,YAAe;EAAA,OAA2B;IACrDH,IAAI,EAAE;EAD+C,CAA3B;AAAA,CAArB;AAIP;AACA;AACA;;;;;AACO,IAAMI,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAAmB,UAACC,QAAD,EAAWC,QAAX,EAAwB;IAAA;;IACvED,QAAQ,CAAC;MACPL,IAAI,EAAE;IADC,CAAD,CAAR;IAIA,IAAMO,OAAO,4BAAGD,QAAQ,GAAGE,MAAX,CAAkBC,QAArB,oFAAG,sBAA4BC,KAA/B,2DAAG,uBAAmCC,KAAnD;IACA,IAAMC,YAAY,6BAAGN,QAAQ,GAAGE,MAAX,CAAkBC,QAArB,qFAAG,uBAA4BC,KAA/B,2DAAG,uBAAmCG,IAAxD;IACA,OAAOR,QAAQ,CACb,IAAAS,aAAA,EAAKC,8BAAL,EAA0B;MACxBF,IAAI,EAAED,YAAY,GAAGA,YAAH,GAAkBN,QAAQ,GAAGE,MAAX,CAAkBC,QAD9B;MAExBE,KAAK,EAAEJ;IAFiB,CAA1B,CADa,CAAf;EAMD,CAb6B;AAAA,CAAvB;AAeP;AACA;;;;;AACO,IAAMS,KAAK,GAChB,SADWA,KACX,CAACC,QAAD,EAAmBC,QAAnB;EAAA,OACA,UAACb,QAAD,EAAc;IACZA,QAAQ,CAAC,IAAAc,gCAAA,GAAD,CAAR;IAEA,OAAO,IAAIC,qBAAJ,GACJJ,KADI,CACEC,QADF,EACYC,QADZ,EAEJG,IAFI,CAEC;MAAA,OAAMhB,QAAQ,CAAC,IAAAiB,8BAAA,GAAD,CAAd;IAAA,CAFD,EAGJD,IAHI,CAGC,YAAM;MACVE,cAAA,CAAMC,OAAN,CAAc,MAAd,EAAsB,IAAtB;;MACAnB,QAAQ,CAACF,YAAY,EAAb,CAAR;MAEA,OAAOE,QAAQ,CAAC,IAAAoB,iCAAA,GAAD,CAAf;IACD,CARI,EASJC,KATI,CASE,UAACC,KAAD,EAAW;MAChB,IAAIA,KAAK,CAACC,EAAN,KAAa,8BAAjB,EAAiD;QAC/C,IAAMC,2BAA2B,GAAGxB,QAAQ,CAAC,IAAAiB,8BAAA,GAAD,CAA5C;QAEA,OAAO,iBAAQQ,OAAR,CAAgBD,2BAAhB,EAA6CR,IAA7C,CAAkD,YAAM;UAC7DE,cAAA,CAAMC,OAAN,CAAc,MAAd,EAAsB,IAAtB;;UACA,OAAOnB,QAAQ,CAACD,cAAc,EAAf,CAAf;QACD,CAHM,CAAP;MAID;;MAEDC,QAAQ,CAACP,WAAW,CAAC6B,KAAK,CAACC,EAAP,CAAZ,CAAR;MACA,OAAOvB,QAAQ,CAAC,IAAAoB,iCAAA,GAAD,CAAf;IACD,CArBI,CAAP;EAsBD,CA1BD;AAAA,CADK"}
1
+ {"version":3,"file":"SignIn.js","names":["loginFailed","errorMessage","sendAuthenticationError","type","payload","resetAuthErrors","loginSuccess","changePassword","dispatch","getState","isModal","router","location","state","modal","locationFrom","from","push","CHANGEPASSWORD_PATH","login","username","password","startProgress","Authenticate","then","reloadApplication","Cache","addItem","finishProgress","catch","error","id","dispatchedReloadApplication","resolve"],"sources":["../../../src/redux/actions/SignIn.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport { reloadApplication } from \"./Application\";\n\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\nimport { push } from \"../_router/actions\";\nimport { CHANGEPASSWORD_PATH } from \"../../constants/Constants\";\n\nimport type {\n SendAuthenticationErrorAction,\n ResetAuthErrorsAction,\n LoginSuccessAction,\n ThunkAction,\n} from \"../types\";\n\n/**\n * Send login failed action\n */\nexport const loginFailed = (\n errorMessage: string\n): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);\n\n/**\n * Send authentication error action\n */\nexport const sendAuthenticationError = (\n errorMessage: string\n): SendAuthenticationErrorAction => ({\n type: \"AUTHENTICATION_ERROR\",\n payload: errorMessage,\n});\n\n/**\n * Resets any authentication errors\n */\nexport const resetAuthErrors = (): ResetAuthErrorsAction => ({\n type: \"AUTHENTICATION_RESET_ERRORS\",\n});\n\n/**\n * Send login success action\n */\nexport const loginSuccess = (): LoginSuccessAction => ({\n type: \"AUTHENTICATION_SUCCESS\",\n});\n\n/**\n * Send change password action\n */\nexport const changePassword = (): ThunkAction => (dispatch, getState) => {\n dispatch({\n type: \"CHANGE_PASSWORD\",\n });\n\n const isModal = getState().router.location?.state?.modal;\n const locationFrom = getState().router.location?.state?.from;\n return dispatch(\n push(CHANGEPASSWORD_PATH, {\n from: locationFrom ? locationFrom : getState().router.location,\n modal: isModal,\n })\n );\n};\n\n/**\n */\nexport const login =\n (username: string, password: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n\n return new Authenticate()\n .login(username, password)\n .then(() => dispatch(reloadApplication()))\n .then(() => {\n Cache.addItem(\"auth\", true);\n dispatch(loginSuccess());\n\n return dispatch(finishProgress());\n })\n .catch((error) => {\n if (error.id === \"Error.ChangePasswordRequired\") {\n const dispatchedReloadApplication = dispatch(reloadApplication());\n\n return Promise.resolve(dispatchedReloadApplication).then(() => {\n Cache.addItem(\"auth\", true);\n return dispatch(changePassword());\n });\n }\n\n dispatch(loginFailed(error.id));\n return dispatch(finishProgress());\n });\n };\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AASA;AACA;AACA;AACO,IAAMA,WAAW,GAAG,SAAdA,WAAc,CACzBC,YADyB;EAAA,OAESC,uBAAuB,CAACD,YAAD,CAFhC;AAAA,CAApB;AAIP;AACA;AACA;;;;;AACO,IAAMC,uBAAuB,GAAG,SAA1BA,uBAA0B,CACrCD,YADqC;EAAA,OAEF;IACnCE,IAAI,EAAE,sBAD6B;IAEnCC,OAAO,EAAEH;EAF0B,CAFE;AAAA,CAAhC;AAOP;AACA;AACA;;;;;AACO,IAAMI,eAAe,GAAG,SAAlBA,eAAkB;EAAA,OAA8B;IAC3DF,IAAI,EAAE;EADqD,CAA9B;AAAA,CAAxB;AAIP;AACA;AACA;;;;;AACO,IAAMG,YAAY,GAAG,SAAfA,YAAe;EAAA,OAA2B;IACrDH,IAAI,EAAE;EAD+C,CAA3B;AAAA,CAArB;AAIP;AACA;AACA;;;;;AACO,IAAMI,cAAc,GAAG,SAAjBA,cAAiB;EAAA,OAAmB,UAACC,QAAD,EAAWC,QAAX,EAAwB;IAAA;;IACvED,QAAQ,CAAC;MACPL,IAAI,EAAE;IADC,CAAD,CAAR;IAIA,IAAMO,OAAO,4BAAGD,QAAQ,GAAGE,MAAX,CAAkBC,QAArB,oFAAG,sBAA4BC,KAA/B,2DAAG,uBAAmCC,KAAnD;IACA,IAAMC,YAAY,6BAAGN,QAAQ,GAAGE,MAAX,CAAkBC,QAArB,qFAAG,uBAA4BC,KAA/B,2DAAG,uBAAmCG,IAAxD;IACA,OAAOR,QAAQ,CACb,IAAAS,aAAA,EAAKC,8BAAL,EAA0B;MACxBF,IAAI,EAAED,YAAY,GAAGA,YAAH,GAAkBN,QAAQ,GAAGE,MAAX,CAAkBC,QAD9B;MAExBE,KAAK,EAAEJ;IAFiB,CAA1B,CADa,CAAf;EAMD,CAb6B;AAAA,CAAvB;AAeP;AACA;;;;;AACO,IAAMS,KAAK,GAChB,SADWA,KACX,CAACC,QAAD,EAAmBC,QAAnB;EAAA,OACA,UAACb,QAAD,EAAc;IACZA,QAAQ,CAAC,IAAAc,gCAAA,GAAD,CAAR;IAEA,OAAO,IAAIC,qBAAJ,GACJJ,KADI,CACEC,QADF,EACYC,QADZ,EAEJG,IAFI,CAEC;MAAA,OAAMhB,QAAQ,CAAC,IAAAiB,8BAAA,GAAD,CAAd;IAAA,CAFD,EAGJD,IAHI,CAGC,YAAM;MACVE,cAAA,CAAMC,OAAN,CAAc,MAAd,EAAsB,IAAtB;;MACAnB,QAAQ,CAACF,YAAY,EAAb,CAAR;MAEA,OAAOE,QAAQ,CAAC,IAAAoB,iCAAA,GAAD,CAAf;IACD,CARI,EASJC,KATI,CASE,UAACC,KAAD,EAAW;MAChB,IAAIA,KAAK,CAACC,EAAN,KAAa,8BAAjB,EAAiD;QAC/C,IAAMC,2BAA2B,GAAGxB,QAAQ,CAAC,IAAAiB,8BAAA,GAAD,CAA5C;QAEA,OAAO,iBAAQQ,OAAR,CAAgBD,2BAAhB,EAA6CR,IAA7C,CAAkD,YAAM;UAC7DE,cAAA,CAAMC,OAAN,CAAc,MAAd,EAAsB,IAAtB;;UACA,OAAOnB,QAAQ,CAACD,cAAc,EAAf,CAAf;QACD,CAHM,CAAP;MAID;;MAEDC,QAAQ,CAACR,WAAW,CAAC8B,KAAK,CAACC,EAAP,CAAZ,CAAR;MACA,OAAOvB,QAAQ,CAAC,IAAAoB,iCAAA,GAAD,CAAf;IACD,CArBI,CAAP;EAsBD,CA1BD;AAAA,CADK"}
@@ -60,15 +60,8 @@ describe("authorization actions", () => {
60
60
  type: "AUTHENTICATION_LOGOUT",
61
61
  },
62
62
  {
63
- type: "SHOW_NOTIFICATION",
64
- payload: {
65
- error: null,
66
- message: {
67
- defaultMessage: "Error.Authentication.InvalidUsername",
68
- id: "Error.Authentication.InvalidUsername",
69
- },
70
- type: "WARNING",
71
- },
63
+ type: "AUTHENTICATION_ERROR",
64
+ payload: "Error.Authentication.InvalidUsername",
72
65
  },
73
66
  {
74
67
  type: "ROUTER/REPLACE",
@@ -114,15 +107,8 @@ describe("authorization actions", () => {
114
107
  type: "AUTHENTICATION_LOGOUT",
115
108
  },
116
109
  {
117
- type: "SHOW_NOTIFICATION",
118
- payload: {
119
- error: null,
120
- message: {
121
- defaultMessage: "Error.Authentication.InvalidUsername",
122
- id: "Error.Authentication.InvalidUsername",
123
- },
124
- type: "WARNING",
125
- },
110
+ type: "AUTHENTICATION_ERROR",
111
+ payload: "Error.Authentication.InvalidUsername",
126
112
  },
127
113
  {
128
114
  type: "ROUTER/REPLACE",
@@ -103,7 +103,7 @@ export type UpdateProgressAction = {
103
103
  payload: { percentComplete: number },
104
104
  };
105
105
 
106
- export type LoginFailedAction = {
106
+ export type SendAuthenticationErrorAction = {
107
107
  type: "AUTHENTICATION_ERROR",
108
108
  payload: string,
109
109
  };
@@ -151,8 +151,8 @@ export type ReduxAction =
151
151
  | FinishProgressAction
152
152
  | ResetProgressAction
153
153
  | UpdateProgressAction
154
- | LoginFailedAction
155
154
  | ResetAuthErrorsAction
155
+ | SendAuthenticationErrorAction
156
156
  | LoginSuccessAction
157
157
  | ChangePasswordAction
158
158
  | LogoutSuccessAction
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type LoginFailedAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | UpdateModelAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | LoginFailedAction\n | ResetAuthErrorsAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | UpdateModelAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.20.1",
3
+ "version": "1.20.4",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -78,7 +78,7 @@
78
78
  "styled-components": "^5.0.0"
79
79
  },
80
80
  "dependencies": {
81
- "@babel/runtime-corejs3": "^7.18.3",
81
+ "@babel/runtime-corejs3": "^7.18.6",
82
82
  "big.js": "^6.2.0",
83
83
  "date-fns": "^2.28.0",
84
84
  "deepmerge": "^4.2.2",
@@ -95,18 +95,18 @@
95
95
  "setimmediate": "^1.0.5"
96
96
  },
97
97
  "devDependencies": {
98
- "@babel/cli": "^7.17.10",
99
- "@babel/core": "^7.18.5",
98
+ "@babel/cli": "^7.18.6",
99
+ "@babel/core": "^7.18.6",
100
100
  "@babel/eslint-parser": "^7.18.2",
101
101
  "@babel/eslint-plugin": "^7.16.5",
102
- "@babel/plugin-proposal-class-properties": "^7.17.12",
102
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
103
103
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
104
- "@babel/plugin-transform-runtime": "^7.18.5",
105
- "@babel/preset-env": "^7.18.2",
106
- "@babel/preset-flow": "^7.17.12",
107
- "@babel/preset-react": "^7.17.12",
108
- "@commitlint/cli": "^17.0.2",
109
- "@commitlint/config-conventional": "^17.0.2",
104
+ "@babel/plugin-transform-runtime": "^7.18.6",
105
+ "@babel/preset-env": "^7.18.6",
106
+ "@babel/preset-flow": "^7.18.6",
107
+ "@babel/preset-react": "^7.18.6",
108
+ "@commitlint/cli": "^17.0.3",
109
+ "@commitlint/config-conventional": "^17.0.3",
110
110
  "@testing-library/react": "^13.3.0",
111
111
  "auditjs": "^4.0.37",
112
112
  "babel-jest": "^28.1.1",
@@ -114,27 +114,27 @@
114
114
  "cherry-pick": "^0.5.0",
115
115
  "cross-env": "^7.0.3",
116
116
  "documentation": "^13.2.5",
117
- "eslint": "^8.17.0",
117
+ "eslint": "^8.18.0",
118
118
  "eslint-config-prettier": "^8.3.0",
119
119
  "eslint-plugin-babel": "^5.3.1",
120
120
  "eslint-plugin-ft-flow": "^2.0.1",
121
121
  "eslint-plugin-import": "^2.26.0",
122
122
  "eslint-plugin-jest": "^26.5.3",
123
- "eslint-plugin-jsdoc": "^39.3.2",
124
- "eslint-plugin-react": "^7.30.0",
123
+ "eslint-plugin-jsdoc": "^39.3.3",
124
+ "eslint-plugin-react": "^7.30.1",
125
125
  "eslint-plugin-react-hooks": "^4.5.0",
126
- "flow-bin": "^0.180.0",
126
+ "flow-bin": "^0.181.1",
127
127
  "flow-copy-source": "^2.0.9",
128
- "flow-typed": "^3.6.1",
128
+ "flow-typed": "^3.8.0",
129
129
  "glob": "^8.0.3",
130
130
  "history": "^4.0.0",
131
131
  "husky": "^8.0.1",
132
132
  "jest": "^28.1.1",
133
133
  "jest-environment-jsdom": "^28.1.1",
134
- "jest-junit": "^13.2.0",
134
+ "jest-junit": "^14.0.0",
135
135
  "jest-sonar-reporter": "^2.0.0",
136
136
  "jscodeshift": "^0.13.1",
137
- "lint-staged": "^13.0.1",
137
+ "lint-staged": "^13.0.3",
138
138
  "polished": "^4.0.0",
139
139
  "prettier": "^2.7.1",
140
140
  "react": "^18.0.0",
@@ -51,21 +51,6 @@ export const UPLOAD_PATH = `${BASE}/uploadFile`;
51
51
  */
52
52
  export const CAPTCHA_PATH = `${BASE}/captchaServices`;
53
53
 
54
- /**
55
- * Path to login page / component
56
- */
57
- export const LOGIN_PATH = "/signin";
58
-
59
- /**
60
- * Path to administrator login page / component
61
- */
62
- export const ADMINISTRATOR_LOGIN_PATH = "/administrator";
63
-
64
- /**
65
- * Path to logout page / component
66
- */
67
- export const LOGOUT_PATH = "/signout";
68
-
69
54
  /**
70
55
  * Path to change password page / component
71
56
  */
@@ -51,6 +51,15 @@ const defaultSettings = {
51
51
  // Renders the login variants as option on the global logout page
52
52
  RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,
53
53
 
54
+ // Path to login page / component
55
+ LOGIN_PATH: "/signin",
56
+
57
+ // Path to administrator login page / component
58
+ ADMINISTRATOR_LOGIN_PATH: "",
59
+
60
+ // Path to logout page / component
61
+ LOGOUT_PATH: "/signout",
62
+
54
63
  // Render forms in a modal
55
64
  RENDER_FORMS_IN_MODAL: true,
56
65
 
@@ -4,32 +4,58 @@ import { useSelector, useDispatch } from "react-redux";
4
4
  import { getApplication } from "../redux/_modularui/selectors";
5
5
  import { login, logout, resetAuthErrors } from "../redux/actions";
6
6
 
7
+ import Cache from "../utils/browser/Cache";
8
+ import { BASE, getSetting } from "../constants";
9
+
7
10
  import type { ResetAuthErrorsAction } from "../redux/types";
11
+ import type { AuthenticationType } from "../models/types";
12
+ import { IllegalStateException } from "../exceptions";
8
13
  type LoginHook = {
9
14
  isAuthenticated: boolean,
15
+ authenticationTypes: Array<AuthenticationType>,
10
16
  errorMessage: ?string,
11
17
  resetErrors: () => ResetAuthErrorsAction,
12
18
  login: (username: string, password: string) => void,
19
+ redirectLogin: (authenticationType: AuthenticationType) => void,
13
20
  };
14
21
  type LogoutHook = {
15
22
  isAuthenticated: boolean,
23
+ authenticationTypes: Array<AuthenticationType>,
16
24
  logout: () => void,
17
25
  };
18
26
 
19
27
  /**
20
28
  */
21
29
  export const useLogin = (): LoginHook => {
30
+ Cache.setItem("isRedirectLogin", false);
31
+
22
32
  const dispatch = useDispatch();
23
33
 
24
34
  const application = useSelector(getApplication);
25
35
  const auth = useSelector((state) => state.auth);
26
36
 
37
+ const isAuthenticated = application?.isLoggedIn ?? false;
38
+
27
39
  return {
28
- isAuthenticated: application?.isLoggedIn ?? false,
40
+ isAuthenticated,
41
+ authenticationTypes: application?.authenticationTypes ?? [],
29
42
  errorMessage: auth.error,
30
43
  resetErrors: () => dispatch(resetAuthErrors()),
31
44
  login: (username: string, password: string) =>
32
45
  dispatch(login(username, password)),
46
+ redirectLogin: (authenticationType: AuthenticationType) => {
47
+ if (Cache.getItem("isRedirectLogin")) {
48
+ // prevent endless loop in redirects when authentication type can't be redirected
49
+ throw new IllegalStateException(
50
+ `Could not redirect to '${authenticationType.authentication}' using url: '${authenticationType.redirectUri}'`
51
+ );
52
+ }
53
+
54
+ if (!isAuthenticated) {
55
+ Cache.setItem("isRedirectLogin", true);
56
+ window.location.assign(`${BASE}${authenticationType.redirectUri}`);
57
+ }
58
+ },
33
59
  };
34
60
  };
35
61
 
@@ -39,8 +65,21 @@ export const useLogout = (): LogoutHook => {
39
65
  const dispatch = useDispatch();
40
66
  const application = useSelector(getApplication);
41
67
 
68
+ const LOGOUT_PATH = getSetting("LOGOUT_PATH", "/signout");
69
+
70
+ const isAuthenticated = application?.isLoggedIn ?? false;
42
71
  return {
43
- isAuthenticated: application?.isLoggedIn ?? false,
44
- logout: () => dispatch(logout()),
72
+ isAuthenticated,
73
+ authenticationTypes: application?.authenticationTypes ?? [],
74
+ logout: () => {
75
+ if (Cache.getItem("isRedirectLogin")) {
76
+ const origin = window.location.origin;
77
+ const url = `${origin}${BASE}/logout?url=${origin}${BASE}${LOGOUT_PATH}`;
78
+ Cache.setItem("isRedirectLogin", false);
79
+ window.location.assign(url);
80
+ } else {
81
+ return dispatch(logout());
82
+ }
83
+ },
45
84
  };
46
85
  };
@@ -31,6 +31,7 @@ export default {
31
31
  "Constraint.File.InvalidFormat": "Must meet the requirements of the file name",
32
32
  "Constraint.File.InvalidMimeType": "Allowed mime types are: ${mime-types}",
33
33
  "Constraint.File.MaxFileSizeExceeded": "Maximum file upload size is ${max-filesize}",
34
+ "Constraint.File.OnlyAllowsOneFile": "Only one file is allowed",
34
35
  "Constraint.IBAN.InvalidFormat": "Must be a valid IBAN number",
35
36
  "Constraint.InvalidLengthBetween": "Length must be between ${min-length} and ${max-length} characters",
36
37
  "Constraint.InvalidLengthExact": "Length must be precisely ${length} characters",
@@ -65,7 +66,7 @@ export default {
65
66
  "Constraint.TimeStampRange.InvalidRange": "Start value must be before end value",
66
67
  "Constraint.TimeStampRange.Mandatory": "Field is mandatory: must contain at least a start or end value",
67
68
  "Constraint.XML.InvalidFormat": "Must be well-formed XML",
68
- "Constraint.ZipCode.InvalidFormat": "Must be a valid Dutch ZIP code, e.g. 1234 AB",
69
+ "Constraint.ZipCode.InvalidFormat": "Must be a valid Dutch ZIP code, e.g. 1234AB",
69
70
  "Error.AcceptHeaderRequired": "The 'Accept' request-header field must be provided",
70
71
  "Error.Authentication.BlockedUser": "You have been logged out, because your account has been blocked",
71
72
  "Error.Authentication.ConcurrentUser": "You have been logged out, since your username has been used at a different location.",
@@ -76,7 +77,7 @@ export default {
76
77
  "Error.ChangePasswordRequired": "User password is initial or expired, and must be changed ",
77
78
  "Error.CodemapLookup.InvalidToken": "Token for codemap lookup is not valid",
78
79
  "Error.DataStore.ConcurrentModification": "Another user has updated a record used in this task",
79
- "Error.DataStore.RecordAlreadyExists": "Row cannot be overwritten because it already exists",
80
+ "Error.DataStore.RecordAlreadyExists": "",
80
81
  "Error.DataStore.RowCannotBeLocked": "Another user has already locked a record used in this task",
81
82
  "Error.Form.DataNotAvailableForId": "Service can not be completed, data not available for mandatory element ${elementid}",
82
83
  "Error.Form.ObjectNotAllowed": "Object '${objectid}' is not allowed",
@@ -31,6 +31,7 @@ export default {
31
31
  "Constraint.File.InvalidFormat": "Voldoet niet aan de voorwaarden van een bestandsnaam",
32
32
  "Constraint.File.InvalidMimeType": "Toegestane mime-types zijn: ${mime-types}",
33
33
  "Constraint.File.MaxFileSizeExceeded": "De maximum file grootte voor upload is ${max-filesize}",
34
+ "Constraint.File.OnlyAllowsOneFile": "Er is slechts één bestand toegestaan",
34
35
  "Constraint.IBAN.InvalidFormat": "Moet een geldig IBAN nummer zijn",
35
36
  "Constraint.InvalidLengthBetween": "Lengte moet tussen ${min-length} en ${max-length} karakters liggen",
36
37
  "Constraint.InvalidLengthExact": "Lengte moet precies ${length} karakters zijn",
@@ -65,18 +66,18 @@ export default {
65
66
  "Constraint.TimeStampRange.InvalidRange": "De beginwaarde dient voor de eindwaarde te liggen",
66
67
  "Constraint.TimeStampRange.Mandatory": "Veld is verplicht: moet tenminste begin- of eindwaarde bevatten",
67
68
  "Constraint.XML.InvalidFormat": "Moet geldige XML zijn",
68
- "Constraint.ZipCode.InvalidFormat": "Moet een geldige postcode zijn, bijvoorbeeld 1234 AB",
69
+ "Constraint.ZipCode.InvalidFormat": "Moet een geldige postcode zijn, bijvoorbeeld 1234AB",
69
70
  "Error.AcceptHeaderRequired": "De 'Accept' request-header moet worden meegegeven",
70
71
  "Error.Authentication.BlockedUser": "U bent uitgelogd omdat uw account geblokkeerd is",
71
72
  "Error.Authentication.ConcurrentUser": "U bent uitgelogd omdat uw gebruikersnaam op een andere locatie is gebruikt om in te loggen.",
72
73
  "Error.Authentication.InvalidCredentials": "Inloggen is mislukt",
73
- "Error.Authentication.InvalidUsername": "\"U bent uitgelogd omdat uw gebruikersnaam niet meer geldig is",
74
+ "Error.Authentication.InvalidUsername": "U bent uitgelogd omdat uw gebruikersnaam niet meer geldig is",
74
75
  "Error.Authentication.Required": "Autorisatie is vereist",
75
76
  "Error.Case.ConcurrentModification": "Een andere gebruiker heeft het dossier aangepast waardoor deze taak nu niet meer is toegestaan",
76
77
  "Error.ChangePasswordRequired": "Gebruikerswachtwoord is initieel of verlopen, en moet worden aangepast",
77
78
  "Error.CodemapLookup.InvalidToken": "Token voor keuzelijst lookup is niet valide",
78
79
  "Error.DataStore.ConcurrentModification": "Een andere gebruiker heeft de rij in de datastore reeds aangepast",
79
- "Error.DataStore.RecordAlreadyExists": "Rij kan niet worden overschreven aangezien deze reeds bestaat",
80
+ "Error.DataStore.RecordAlreadyExists": "",
80
81
  "Error.DataStore.RowCannotBeLocked": "Een andere gebruiker heeft de rij in bewerking en daarom kan deze taak niet worden volbracht.",
81
82
  "Error.Form.DataNotAvailableForId": "Service kan niet worden afgrond, data voor verplicht element ${elementid} is niet beschikbaar",
82
83
  "Error.Form.ObjectNotAllowed": "Object '${objectid}' is niet toegestaan",
@@ -68,7 +68,13 @@ export default class ApplicationModel extends ResourceModel {
68
68
  * Getting the authentication types of the application
69
69
  */
70
70
  get authenticationTypes(): Array<AuthenticationType> {
71
- return this.getContribution("security", []);
71
+ const authenticationTypes = this.getContribution("security", []);
72
+
73
+ //put primary first
74
+ return authenticationTypes?.sort(
75
+ (a: AuthenticationType, b: AuthenticationType) =>
76
+ a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1
77
+ );
72
78
  }
73
79
  /**
74
80
  * Getting the tab links
@@ -116,10 +116,7 @@ export const loadModel = (
116
116
  return {
117
117
  type: "NO_ACTION",
118
118
  };
119
- } else if (
120
- errorResponse.isResourceNotFoundAfterReload ||
121
- errorResponse.isInvalidUsername
122
- ) {
119
+ } else if (errorResponse.isResourceNotFoundAfterReload) {
123
120
  return removeModelByKey(key);
124
121
  }
125
122
 
@@ -1,11 +1,8 @@
1
1
  // @flow
2
- import { LOGIN_PATH, NOTIFICATION_TYPES } from "../../constants/Constants";
3
-
4
2
  import ErrorResponse from "../../models/error/ErrorResponse";
5
3
 
6
4
  import { replace } from "../_router/actions";
7
5
  import { logoutSuccess } from "./SignOut";
8
- import { showNotification } from "./Notification";
9
6
 
10
7
  import Cache from "../../utils/browser/Cache";
11
8
 
@@ -16,6 +13,7 @@ import { reloadApplication } from "./Application";
16
13
  import { getSetting } from "../../constants";
17
14
 
18
15
  import type { ThunkAction } from "../types";
16
+ import { sendAuthenticationError } from "./SignIn";
19
17
 
20
18
  /**
21
19
  */
@@ -40,28 +38,18 @@ export const handleUnauthorized =
40
38
  dispatch(reloadApplication());
41
39
  }
42
40
 
43
- // set logged auth
41
+ // set logged out
44
42
  dispatch(logoutSuccess());
45
43
 
46
44
  Cache.removeItem("auth");
47
45
 
48
46
  if (errorResponse.isInvalidUsername) {
49
- const WARNING_TIMEOUT = 4000;
50
- dispatch(
51
- showNotification(
52
- NOTIFICATION_TYPES.WARNING,
53
- {
54
- id: errorResponse.id,
55
- defaultMessage: errorResponse.message,
56
- },
57
- null,
58
- WARNING_TIMEOUT
59
- )
60
- );
47
+ dispatch(sendAuthenticationError(errorResponse.message));
61
48
  }
62
49
 
63
50
  // add current location as from location before redirect
64
51
  const location = getState().router.location;
52
+ const LOGIN_PATH = getSetting("LOGIN_PATH", "/signin");
65
53
  if (location?.pathname !== LOGIN_PATH) {
66
54
  const locationFrom = location?.state?.from;
67
55
  return dispatch(
@@ -1,5 +1,6 @@
1
1
  // @flow
2
- import { LOGOUT_PATH, IS_SERVER } from "../../constants/Constants";
2
+ import { IS_SERVER } from "../../constants/Constants";
3
+ import { getSetting } from "../../constants/Settings";
3
4
 
4
5
  import ErrorResponse from "../../models/error/ErrorResponse";
5
6
 
@@ -39,6 +40,7 @@ const defaultErrorResponseHandler: DefaultErrorResponseHandler =
39
40
  }
40
41
 
41
42
  if (error.isBlocked || error.isConcurrentUser) {
43
+ const LOGOUT_PATH = getSetting("LOGOUT_PATH", "/signout");
42
44
  dispatch(push(LOGOUT_PATH));
43
45
  }
44
46
 
@@ -9,7 +9,7 @@ import { push } from "../_router/actions";
9
9
  import { CHANGEPASSWORD_PATH } from "../../constants/Constants";
10
10
 
11
11
  import type {
12
- LoginFailedAction,
12
+ SendAuthenticationErrorAction,
13
13
  ResetAuthErrorsAction,
14
14
  LoginSuccessAction,
15
15
  ThunkAction,
@@ -18,7 +18,16 @@ import type {
18
18
  /**
19
19
  * Send login failed action
20
20
  */
21
- export const loginFailed = (errorMessage: string): LoginFailedAction => ({
21
+ export const loginFailed = (
22
+ errorMessage: string
23
+ ): SendAuthenticationErrorAction => sendAuthenticationError(errorMessage);
24
+
25
+ /**
26
+ * Send authentication error action
27
+ */
28
+ export const sendAuthenticationError = (
29
+ errorMessage: string
30
+ ): SendAuthenticationErrorAction => ({
22
31
  type: "AUTHENTICATION_ERROR",
23
32
  payload: errorMessage,
24
33
  });
@@ -60,15 +60,8 @@ describe("authorization actions", () => {
60
60
  type: "AUTHENTICATION_LOGOUT",
61
61
  },
62
62
  {
63
- type: "SHOW_NOTIFICATION",
64
- payload: {
65
- error: null,
66
- message: {
67
- defaultMessage: "Error.Authentication.InvalidUsername",
68
- id: "Error.Authentication.InvalidUsername",
69
- },
70
- type: "WARNING",
71
- },
63
+ type: "AUTHENTICATION_ERROR",
64
+ payload: "Error.Authentication.InvalidUsername",
72
65
  },
73
66
  {
74
67
  type: "ROUTER/REPLACE",
@@ -114,15 +107,8 @@ describe("authorization actions", () => {
114
107
  type: "AUTHENTICATION_LOGOUT",
115
108
  },
116
109
  {
117
- type: "SHOW_NOTIFICATION",
118
- payload: {
119
- error: null,
120
- message: {
121
- defaultMessage: "Error.Authentication.InvalidUsername",
122
- id: "Error.Authentication.InvalidUsername",
123
- },
124
- type: "WARNING",
125
- },
110
+ type: "AUTHENTICATION_ERROR",
111
+ payload: "Error.Authentication.InvalidUsername",
126
112
  },
127
113
  {
128
114
  type: "ROUTER/REPLACE",
@@ -103,7 +103,7 @@ export type UpdateProgressAction = {
103
103
  payload: { percentComplete: number },
104
104
  };
105
105
 
106
- export type LoginFailedAction = {
106
+ export type SendAuthenticationErrorAction = {
107
107
  type: "AUTHENTICATION_ERROR",
108
108
  payload: string,
109
109
  };
@@ -151,8 +151,8 @@ export type ReduxAction =
151
151
  | FinishProgressAction
152
152
  | ResetProgressAction
153
153
  | UpdateProgressAction
154
- | LoginFailedAction
155
154
  | ResetAuthErrorsAction
155
+ | SendAuthenticationErrorAction
156
156
  | LoginSuccessAction
157
157
  | ChangePasswordAction
158
158
  | LogoutSuccessAction