@antscorp/antsomi-ui 1.3.7-beta.7 → 1.3.7-beta.71
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/README.md +70 -0
- package/es/components/atoms/Input/Input.js +3 -1
- package/es/components/atoms/InputDynamic/InputDynamic.js +3 -3
- package/es/components/atoms/Tag/Tag.js +1 -1
- package/es/components/icons/LazyIcon/LazyIcon.d.ts +2 -0
- package/es/components/icons/LazyIcon/LazyIcon.js +2 -0
- package/es/components/icons/QRCodeManagementIcon.d.ts +3 -0
- package/es/components/icons/QRCodeManagementIcon.js +7 -0
- package/es/components/icons/QRSetDashboardIcon.d.ts +3 -0
- package/es/components/icons/QRSetDashboardIcon.js +7 -0
- package/es/components/icons/index.d.ts +2 -0
- package/es/components/icons/index.js +2 -0
- package/es/components/molecules/AddDynamicContent/AddDynamicContent.js +28 -2
- package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +1 -0
- package/es/components/molecules/AddDynamicContent/constants.d.ts +2 -0
- package/es/components/molecules/AddDynamicContent/constants.js +2 -0
- package/es/components/molecules/ColorPicker/index.d.ts +2 -0
- package/es/components/molecules/ColorPicker/index.js +8 -3
- package/es/components/molecules/EmojiPopover/EmojiPopover.d.ts +1 -0
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +2 -2
- package/es/components/molecules/EmojiPopover/styled.d.ts +2 -2
- package/es/components/molecules/EmojiPopover/styled.js +1 -1
- package/es/components/molecules/EmptyData/EmptyData.d.ts +1 -1
- package/es/components/molecules/EmptyData/EmptyData.js +4 -2
- package/es/components/molecules/HeaderV2/HeaderV2.d.ts +1 -1
- package/es/components/molecules/InputSearch/index.d.ts +1 -1
- package/es/components/molecules/InputSearch/index.js +2 -1
- package/es/components/molecules/Modal/Modal.js +7 -1
- package/es/components/molecules/ModalV2/ModalV2.js +2 -1
- package/es/components/molecules/SearchPopover/SearchPopover.js +2 -2
- package/es/components/molecules/SearchPopover/styled.d.ts +12 -1
- package/es/components/molecules/SearchPopover/styled.js +1 -2
- package/es/components/molecules/SearchPopover/types.d.ts +4 -3
- package/es/components/molecules/Select/Select.js +3 -3
- package/es/components/molecules/Select/styled.d.ts +3 -1
- package/es/components/molecules/Select/styled.js +50 -6
- package/es/components/molecules/ShareAccess/ShareAccess.d.ts +2 -1
- package/es/components/molecules/ShareAccess/ShareAccess.js +12 -9
- package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +5 -5
- package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +2 -2
- package/es/components/molecules/ShareAccess/hooks/useShareAccess.d.ts +2 -1
- package/es/components/molecules/ShareAccess/index.d.ts +1 -0
- package/es/components/molecules/ShareAccess/reducer.d.ts +1 -1
- package/es/components/molecules/ShareAccess/reducer.js +7 -4
- package/es/components/molecules/ShareAccess/types.d.ts +22 -0
- package/es/components/molecules/ShareAccess/utils.d.ts +3 -1
- package/es/components/molecules/ShareAccess/utils.js +35 -2
- package/es/components/molecules/TagifyInput/TagifyInput.js +48 -27
- package/es/components/molecules/TagifyInput/types.d.ts +14 -8
- package/es/components/molecules/TagifyInput/utils.d.ts +6 -1
- package/es/components/molecules/TagifyInput/utils.js +19 -0
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +3 -7
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +10 -10
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -327
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.d.ts +9 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/index.js +5 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +23 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.js +81 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.js +32 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +26 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.js +93 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.d.ts +24 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useTreeState.js +94 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.d.ts +7 -0
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useVisibleItems.js +132 -0
- package/es/components/molecules/VirtualizedMenu/styled.js +14 -3
- package/es/components/molecules/VirtualizedMenu/types.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +1 -0
- package/es/components/molecules/VirtualizedMenu/utils.js +1 -0
- package/es/components/molecules/index.d.ts +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.d.ts +1 -0
- package/es/components/organism/AccountSharing/AccountSharing.js +17 -33
- package/es/components/organism/AccountSharing/styled.js +1 -1
- package/es/components/organism/ActivityTimeline/ActivityTimeline.js +3 -3
- package/es/components/organism/ActivityTimeline/constants.d.ts +9 -9
- package/es/components/organism/ActivityTimeline/constants.js +3 -3
- package/es/components/organism/ActivityTimeline/index.d.ts +530 -1
- package/es/components/organism/ActivityTimeline/index.js +9 -1
- package/es/components/organism/ActivityTimeline/utils.js +186 -15
- package/es/components/organism/LeftMenu/LeftMenu.js +6 -6
- package/es/components/organism/LeftMenu/hooks/usePermission.js +1 -1
- package/es/components/organism/LeftMenu/styled.js +2 -0
- package/es/components/organism/LeftMenu/types/index.d.ts +7 -0
- package/es/components/organism/LeftMenu/utils/index.js +1 -1
- package/es/components/organism/Login/Login.js +19 -36
- package/es/components/organism/Login/components/IconInfo/IconInfo.js +1 -1
- package/es/components/organism/Login/components/LoginSelectPortal/LoginSelectPortal.js +1 -1
- package/es/components/organism/Login/components/SignIn/SignIn.js +2 -2
- package/es/components/organism/Login/types/index.d.ts +2 -0
- package/es/components/organism/LoginV2/LoginV2.d.ts +3 -0
- package/es/components/organism/LoginV2/LoginV2.js +957 -0
- package/es/components/organism/LoginV2/components/Avatar/Avatar.d.ts +8 -0
- package/es/components/organism/LoginV2/components/Avatar/Avatar.js +11 -0
- package/es/components/organism/LoginV2/components/Avatar/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/Avatar/index.js +1 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/ChooseMethod.d.ts +9 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/ChooseMethod.js +54 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/Method.d.ts +10 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/Method.js +13 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/index.js +1 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/styled.d.ts +10 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/styled.js +24 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/utils.d.ts +1 -0
- package/es/components/organism/LoginV2/components/ChooseMethod/utils.js +1 -0
- package/es/components/organism/LoginV2/components/ForgotPassword/ForgotPassword.d.ts +14 -0
- package/es/components/organism/LoginV2/components/ForgotPassword/ForgotPassword.js +195 -0
- package/es/components/organism/LoginV2/components/ForgotPassword/index.d.ts +2 -0
- package/es/components/organism/LoginV2/components/ForgotPassword/index.js +2 -0
- package/es/components/organism/LoginV2/components/ForgotPassword/styled.d.ts +1 -0
- package/es/components/organism/LoginV2/components/ForgotPassword/styled.js +10 -0
- package/es/components/organism/LoginV2/components/IconInfo/IconInfo.d.ts +7 -0
- package/es/components/organism/LoginV2/components/IconInfo/IconInfo.js +18 -0
- package/es/components/organism/LoginV2/components/IconInfo/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/IconInfo/index.js +1 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/Item/Item.d.ts +10 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/Item/Item.js +12 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/Item/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/Item/index.js +1 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/Item/styled.d.ts +2 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/Item/styled.js +34 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/LoginSelectPortal.d.ts +19 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/LoginSelectPortal.js +194 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/index.js +1 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/styled.d.ts +1 -0
- package/es/components/organism/LoginV2/components/LoginSelectPortal/styled.js +5 -0
- package/es/components/organism/LoginV2/components/LoginWithEmail/LoginWithEmail.d.ts +15 -0
- package/es/components/organism/LoginV2/components/LoginWithEmail/LoginWithEmail.js +211 -0
- package/es/components/organism/LoginV2/components/LoginWithEmail/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/LoginWithEmail/index.js +1 -0
- package/es/components/organism/LoginV2/components/LoginWithEmail/styled.d.ts +3 -0
- package/es/components/organism/LoginV2/components/LoginWithEmail/styled.js +5 -0
- package/es/components/organism/LoginV2/components/LoginWithGG/LoginWithGG.d.ts +14 -0
- package/es/components/organism/LoginV2/components/LoginWithGG/LoginWithGG.js +116 -0
- package/es/components/organism/LoginV2/components/LoginWithGG/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/LoginWithGG/index.js +1 -0
- package/es/components/organism/LoginV2/components/LoginWithGG/styled.d.ts +3 -0
- package/es/components/organism/LoginV2/components/LoginWithGG/styled.js +5 -0
- package/es/components/organism/LoginV2/components/Logo/Logo.d.ts +6 -0
- package/es/components/organism/LoginV2/components/Logo/Logo.js +9 -0
- package/es/components/organism/LoginV2/components/Logo/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/Logo/index.js +1 -0
- package/es/components/organism/LoginV2/components/OryConsent/OryAuthLayout.d.ts +9 -0
- package/es/components/organism/LoginV2/components/OryConsent/OryAuthLayout.js +4 -0
- package/es/components/organism/LoginV2/components/OryConsent/OryConsent.d.ts +17 -0
- package/es/components/organism/LoginV2/components/OryConsent/OryConsent.js +204 -0
- package/es/components/organism/LoginV2/components/OryConsent/OryThemeProvider.d.ts +8 -0
- package/es/components/organism/LoginV2/components/OryConsent/OryThemeProvider.js +10 -0
- package/es/components/organism/LoginV2/components/OryConsent/PortalSelect.d.ts +15 -0
- package/es/components/organism/LoginV2/components/OryConsent/PortalSelect.js +30 -0
- package/es/components/organism/LoginV2/components/OryConsent/ScopeConsent.d.ts +20 -0
- package/es/components/organism/LoginV2/components/OryConsent/ScopeConsent.js +29 -0
- package/es/components/organism/LoginV2/components/OryConsent/index.d.ts +2 -0
- package/es/components/organism/LoginV2/components/OryConsent/index.js +2 -0
- package/es/components/organism/LoginV2/components/OryConsent/styled.d.ts +31 -0
- package/es/components/organism/LoginV2/components/OryConsent/styled.js +292 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryFormShell.d.ts +9 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryFormShell.js +36 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryMfa.d.ts +11 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryMfa.js +144 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryRecovery.d.ts +9 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryRecovery.js +128 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryStatus.d.ts +17 -0
- package/es/components/organism/LoginV2/components/OrySignIn/OryStatus.js +33 -0
- package/es/components/organism/LoginV2/components/OrySignIn/index.d.ts +3 -0
- package/es/components/organism/LoginV2/components/OrySignIn/index.js +3 -0
- package/es/components/organism/LoginV2/components/SetupGGAuthenticator/SetupGGAuthenticator.d.ts +14 -0
- package/es/components/organism/LoginV2/components/SetupGGAuthenticator/SetupGGAuthenticator.js +100 -0
- package/es/components/organism/LoginV2/components/SetupGGAuthenticator/index.d.ts +2 -0
- package/es/components/organism/LoginV2/components/SetupGGAuthenticator/index.js +2 -0
- package/es/components/organism/LoginV2/components/SetupGGAuthenticator/styled.d.ts +4 -0
- package/es/components/organism/LoginV2/components/SetupGGAuthenticator/styled.js +10 -0
- package/es/components/organism/LoginV2/components/SignIn/SignIn.d.ts +22 -0
- package/es/components/organism/LoginV2/components/SignIn/SignIn.js +107 -0
- package/es/components/organism/LoginV2/components/SignIn/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/SignIn/index.js +1 -0
- package/es/components/organism/LoginV2/components/SignIn/styled.d.ts +3 -0
- package/es/components/organism/LoginV2/components/SignIn/styled.js +10 -0
- package/es/components/organism/LoginV2/components/VerifyAccount/VerifyAccount.d.ts +25 -0
- package/es/components/organism/LoginV2/components/VerifyAccount/VerifyAccount.js +42 -0
- package/es/components/organism/LoginV2/components/VerifyAccount/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/VerifyAccount/index.js +1 -0
- package/es/components/organism/LoginV2/components/VerifyAccount/styled.d.ts +22 -0
- package/es/components/organism/LoginV2/components/VerifyAccount/styled.js +17 -0
- package/es/components/organism/LoginV2/components/WidgetLayout/WidgetLayout.d.ts +13 -0
- package/es/components/organism/LoginV2/components/WidgetLayout/WidgetLayout.js +18 -0
- package/es/components/organism/LoginV2/components/WidgetLayout/index.d.ts +1 -0
- package/es/components/organism/LoginV2/components/WidgetLayout/index.js +1 -0
- package/es/components/organism/LoginV2/components/WidgetLayout/styled.d.ts +5 -0
- package/es/components/organism/LoginV2/components/WidgetLayout/styled.js +22 -0
- package/es/components/organism/LoginV2/components/index.d.ts +11 -0
- package/es/components/organism/LoginV2/components/index.js +11 -0
- package/es/components/organism/LoginV2/constants/index.d.ts +48 -0
- package/es/components/organism/LoginV2/constants/index.js +48 -0
- package/es/components/organism/LoginV2/hooks/index.d.ts +1 -0
- package/es/components/organism/LoginV2/hooks/index.js +1 -0
- package/es/components/organism/LoginV2/hooks/useResize.d.ts +7 -0
- package/es/components/organism/LoginV2/hooks/useResize.js +21 -0
- package/es/components/organism/LoginV2/index.d.ts +6 -0
- package/es/components/organism/LoginV2/index.js +4 -0
- package/es/components/organism/LoginV2/styled.d.ts +51 -0
- package/es/components/organism/LoginV2/styled.js +129 -0
- package/es/components/organism/LoginV2/types/index.d.ts +79 -0
- package/es/components/organism/LoginV2/types/index.js +1 -0
- package/es/components/organism/LoginV2/types/ory.d.ts +52 -0
- package/es/components/organism/LoginV2/types/ory.js +1 -0
- package/es/components/organism/LoginV2/utils/index.d.ts +14 -0
- package/es/components/organism/LoginV2/utils/index.js +49 -0
- package/es/components/organism/LoginV2/utils/ory.d.ts +138 -0
- package/es/components/organism/LoginV2/utils/ory.js +408 -0
- package/es/components/organism/LoginV2/utils/oryConsent.d.ts +52 -0
- package/es/components/organism/LoginV2/utils/oryConsent.js +174 -0
- package/es/components/organism/LoginV2/utils/oryFlows.d.ts +100 -0
- package/es/components/organism/LoginV2/utils/oryFlows.js +319 -0
- package/es/components/organism/TextEditor/TextEditor.d.ts +9 -2
- package/es/components/organism/TextEditor/TextEditor.js +203 -42
- package/es/components/organism/TextEditor/constants.d.ts +9 -0
- package/es/components/organism/TextEditor/constants.js +66 -0
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +6 -128
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +7 -292
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +1 -1
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +4 -0
- package/es/components/organism/TextEditor/extensions/Link.js +33 -14
- package/es/components/organism/TextEditor/extensions/ListItem.d.ts +10 -0
- package/es/components/organism/TextEditor/extensions/ListItem.js +93 -0
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +5 -6
- package/es/components/organism/TextEditor/extensions/SmartTag.js +96 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.js +7 -0
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +2 -1
- package/es/components/organism/TextEditor/index.d.ts +7 -5
- package/es/components/organism/TextEditor/index.scss +4 -7
- package/es/components/organism/TextEditor/provider.d.ts +1 -0
- package/es/components/organism/TextEditor/provider.js +6 -3
- package/es/components/organism/TextEditor/store.d.ts +11 -4
- package/es/components/organism/TextEditor/store.js +22 -2
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/froala-legacy-format.settings.json +95 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.d.ts +111 -0
- package/es/components/organism/TextEditor/stories/WithOldDynAndLink/shared.js +82 -0
- package/es/components/organism/TextEditor/stories/shared.d.ts +64 -0
- package/es/components/organism/TextEditor/stories/shared.js +57 -0
- package/es/components/organism/TextEditor/styled.d.ts +1 -1
- package/es/components/organism/TextEditor/styled.js +1 -0
- package/es/components/organism/TextEditor/types.d.ts +161 -11
- package/es/components/organism/TextEditor/types.js +1 -0
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +2 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +80 -51
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +1 -1
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +1 -1
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +2 -2
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +12 -2
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.d.ts +16 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/LinkInsertForm.js +61 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkInsertForm/index.js +1 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.d.ts +9 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/LinkPopover.js +126 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.d.ts +2 -0
- package/es/components/organism/TextEditor/ui/LinkPopover/index.js +1 -0
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +1 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +1 -3
- package/es/components/organism/TextEditor/ui/Toolbar/{Toolbar.d.ts → FormattingToolbar.d.ts} +3 -4
- package/es/components/organism/TextEditor/ui/Toolbar/FormattingToolbar.js +90 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.d.ts +10 -0
- package/es/components/organism/TextEditor/ui/Toolbar/LinkPreviewToolbar.js +39 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +4 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +1 -0
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +2 -2
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +6 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +2 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +2 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +14 -0
- package/es/components/organism/TextEditor/utils/documentState.js +25 -0
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +60 -0
- package/es/components/organism/TextEditor/utils/link.d.ts +10 -1
- package/es/components/organism/TextEditor/utils/link.js +161 -7
- package/es/components/organism/TextEditor/utils/menu.js +2 -1
- package/es/components/organism/TextEditor/utils/selection.js +3 -2
- package/es/components/organism/TextEditor/utils/smartTag.js +2 -1
- package/es/components/organism/index.d.ts +3 -1
- package/es/components/organism/index.js +1 -0
- package/es/components/template/TemplateListing/Loadable.d.ts +1 -0
- package/es/hooks/index.d.ts +1 -1
- package/es/hooks/index.js +1 -1
- package/es/providers/ConfigProvider/ConfigProvider.d.ts +4 -0
- package/es/providers/ConfigProvider/ConfigProvider.js +2 -3
- package/es/providers/ConfigProvider/GlobalStyle.d.ts +2 -2
- package/es/providers/ConfigProvider/GlobalStyle.js +67 -64
- package/es/services/MediaTemplateDesign/UploadFile/index.js +4 -4
- package/es/utils/common.d.ts +1 -1
- package/es/utils/common.js +3 -3
- package/es/utils/cookie.js +2 -1
- package/es/utils/crossSubdomainCookieOptions.d.ts +14 -0
- package/es/utils/crossSubdomainCookieOptions.js +12 -0
- package/package.json +26 -30
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/BubbleToolbar.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.d.ts +0 -0
- package/es/components/organism/TextEditor/ui/BubbleToolbar/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -39
|
@@ -0,0 +1,957 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable func-names */
|
|
3
|
+
/* eslint-disable no-empty */
|
|
4
|
+
/* eslint-disable no-return-assign */
|
|
5
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
6
|
+
/* eslint-disable no-prototype-builtins */
|
|
7
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
|
8
|
+
/// Libraries
|
|
9
|
+
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
10
|
+
import { CookiesProvider, useCookies } from 'react-cookie';
|
|
11
|
+
import { get } from 'lodash';
|
|
12
|
+
import axios from 'axios';
|
|
13
|
+
import { isMobile } from 'react-device-detect';
|
|
14
|
+
// Components
|
|
15
|
+
import { LoginSelectPortal, LoginWithGG, SignIn, VerifyAccount, SetupGGAuthenticator, ForgotPassword, ChooseMethod, LoginWithEmail, OryConsent, } from './components';
|
|
16
|
+
import { OryThemeProvider } from './components/OryConsent/OryThemeProvider';
|
|
17
|
+
import { describeOryFailure, OryMfa, OryRecovery, OryStatus, } from './components/OrySignIn';
|
|
18
|
+
// Hooks
|
|
19
|
+
import { useContainerDimensions } from './hooks';
|
|
20
|
+
// Utils
|
|
21
|
+
import { checkURL, navigateTo } from './utils';
|
|
22
|
+
import { createCrossSubdomainCookieOptions } from '@antscorp/antsomi-ui/es/utils/crossSubdomainCookieOptions';
|
|
23
|
+
import { checkOrySession, completeOryAuthorization, DEFAULT_OAUTH_STORAGE_KEY, DEFAULT_OAUTH_TOKEN_URL, getOAuthBridgeURL, isOryCallbackRequest, isOryLoginRequest, resolveOryLogin, startOryAuthorization, submitOryPasswordLogin, startOryLogout, } from './utils/ory';
|
|
24
|
+
import { isOryRecoveryRequest } from './utils/oryFlows';
|
|
25
|
+
import { LOGIN_METHODS, STEPS } from './constants';
|
|
26
|
+
import { LoginBannerZone, LoginMain, WrapperLogin } from './styled';
|
|
27
|
+
export const LoginV2 = props => {
|
|
28
|
+
const { loginDomain = 'http://khanhhv.platform-ants.adxdev.vn', onLoginSuccess, onLoginFail, reCaptchaKey = '6LfqGF0UAAAAAFJri0tlp8eCNbWZdJv1eAyF4oIo', p_id, onResendPassFail, u_ogs, callbackUrl, apiDomain = '', usePrivilege, useOry = false, oauthAutoStart = false, oauthLoginUrl, oauthAuthorizeUrl, oauthTokenUrl, oauthClientId, oauthRedirectUri, oauthScope, oauthAudience, oauthStorageKey, kratosLoginUrl, kratosLogoutUrl, kratosRecoveryUrl, sessionUrl, oauthConsentUrl = '/oauth2/consent', oauthCsrfUrl, oauthScopeCatalog, oauthConsentPreview, onOAuthSuccess, onOryAuthenticated, } = props;
|
|
29
|
+
let { networkId } = props;
|
|
30
|
+
networkId = !networkId || typeof networkId === 'boolean' ? undefined : networkId;
|
|
31
|
+
const domainLogin = loginDomain.endsWith('/') ? loginDomain : `${loginDomain}/`;
|
|
32
|
+
const loginUrl = `${domainLogin}api/account/authenticate`;
|
|
33
|
+
const [step, setStep] = useState(STEPS.STEP1);
|
|
34
|
+
const [loginData, setLoginData] = useState({});
|
|
35
|
+
const [isLoginGG, setIsLoginGG] = useState(false);
|
|
36
|
+
const [urlLogo, setUrlLogo] = useState('');
|
|
37
|
+
const [isLoading, setLoading] = useState(false);
|
|
38
|
+
const [isLoadingSkip, setLoadingSkip] = useState(false);
|
|
39
|
+
const [cookies, setCookie] = useCookies();
|
|
40
|
+
const selectedNetworkRef = useRef(null);
|
|
41
|
+
const listNetworkRef = useRef(null);
|
|
42
|
+
const listAccountsRef = useRef(null);
|
|
43
|
+
const authenInfoRef = useRef(null);
|
|
44
|
+
const loginRef = useRef(null);
|
|
45
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
46
|
+
const explicitOry = useOry === true || useOry === 'true';
|
|
47
|
+
const hasOAuthConfig = Boolean(oauthClientId || oauthAuthorizeUrl || oauthTokenUrl || oauthRedirectUri || oauthScope);
|
|
48
|
+
// A generic `?code` or `?error` belongs to the legacy login flow unless this
|
|
49
|
+
// package was explicitly configured for OAuth. Challenge URLs can enter the
|
|
50
|
+
// bridge path, where the server validates the Ory challenge and session.
|
|
51
|
+
const oryRecoveryRequest = explicitOry && isOryRecoveryRequest(window.location);
|
|
52
|
+
const oryCallback = !oryRecoveryRequest && (explicitOry || hasOAuthConfig) && isOryCallbackRequest({ location: window.location });
|
|
53
|
+
const oryBridgeRequest = !oryRecoveryRequest && isOryLoginRequest({ location: window.location });
|
|
54
|
+
const oryConsentRequest = explicitOry && !oryRecoveryRequest && (Boolean(searchParams.get('consent_challenge')) || Boolean(oauthConsentPreview));
|
|
55
|
+
const oryEnabled = explicitOry || oryCallback || oryBridgeRequest;
|
|
56
|
+
const [oryChallengeState, setOryChallengeState] = useState('checking');
|
|
57
|
+
const oryPasswordForm = !oryCallback &&
|
|
58
|
+
!oryConsentRequest &&
|
|
59
|
+
explicitOry &&
|
|
60
|
+
(oryRecoveryRequest || (oauthAutoStart === false && !oryBridgeRequest) ||
|
|
61
|
+
(oryBridgeRequest && oryChallengeState === 'sign-in'));
|
|
62
|
+
const [oryError, setOryError] = useState(null);
|
|
63
|
+
// Which step of the Ory sign-in column is showing: the form, the second factor,
|
|
64
|
+
// or password recovery.
|
|
65
|
+
const [oryView, setOryView] = useState(oryRecoveryRequest ? 'recovery' : 'password');
|
|
66
|
+
const oryFlowStarted = useRef(false);
|
|
67
|
+
const oryFlowActive = useRef(false);
|
|
68
|
+
const beginOryAuthorization = () => startOryAuthorization({
|
|
69
|
+
location: window.location,
|
|
70
|
+
authorizeUrl: oauthAuthorizeUrl || `${domainLogin.replace(/\/$/, '')}/api/account/oauth-authenticate`,
|
|
71
|
+
clientId: oauthClientId,
|
|
72
|
+
redirectUri: oauthRedirectUri,
|
|
73
|
+
scope: oauthScope,
|
|
74
|
+
audience: oauthAudience,
|
|
75
|
+
storageKey: oauthStorageKey,
|
|
76
|
+
assign: url => window.location.assign(url),
|
|
77
|
+
});
|
|
78
|
+
const continueAfterMfa = async () => {
|
|
79
|
+
if (oryBridgeRequest) {
|
|
80
|
+
window.location.assign(getOAuthBridgeURL({
|
|
81
|
+
location: window.location,
|
|
82
|
+
oauthLoginUrl: oauthLoginUrl || `${domainLogin.replace(/\/$/, '')}/oauth2/login`,
|
|
83
|
+
}));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (onOryAuthenticated) {
|
|
87
|
+
await onOryAuthenticated(await checkOrySession({ sessionUrl }));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
await beginOryAuthorization();
|
|
91
|
+
};
|
|
92
|
+
const handleOryPasswordSubmit = async ({ email, password, }) => {
|
|
93
|
+
if (oryBridgeRequest) {
|
|
94
|
+
const result = await submitOryPasswordLogin({
|
|
95
|
+
location: window.location,
|
|
96
|
+
email,
|
|
97
|
+
password,
|
|
98
|
+
kratosLoginUrl,
|
|
99
|
+
sessionUrl,
|
|
100
|
+
oauthLoginUrl: oauthLoginUrl || `${domainLogin.replace(/\/$/, '')}/oauth2/login`,
|
|
101
|
+
inlineMfa: true,
|
|
102
|
+
assign: url => window.location.assign(url),
|
|
103
|
+
});
|
|
104
|
+
if (result.status === 'mfa-required')
|
|
105
|
+
setOryView('mfa');
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const result = await submitOryPasswordLogin({
|
|
109
|
+
location: window.location,
|
|
110
|
+
email,
|
|
111
|
+
password,
|
|
112
|
+
kratosLoginUrl,
|
|
113
|
+
sessionUrl,
|
|
114
|
+
returnToBridge: false,
|
|
115
|
+
inlineMfa: true,
|
|
116
|
+
});
|
|
117
|
+
if (result.status === 'mfa-required') {
|
|
118
|
+
setOryView('mfa');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (onOryAuthenticated && result.status === 'authenticated') {
|
|
122
|
+
await onOryAuthenticated(result.session);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
await beginOryAuthorization();
|
|
126
|
+
};
|
|
127
|
+
// Where "try again" leads: the page that started the flow, without callback parameters.
|
|
128
|
+
const restartOryFlow = () => window.location.assign(oauthRedirectUri || window.location.pathname);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
if (!oryEnabled || oryConsentRequest || (oryPasswordForm && !oryBridgeRequest)) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (oryBridgeRequest && explicitOry && oryChallengeState !== 'checking') {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
oryFlowActive.current = true;
|
|
137
|
+
if (oryFlowStarted.current) {
|
|
138
|
+
return () => {
|
|
139
|
+
oryFlowActive.current = false;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
oryFlowStarted.current = true;
|
|
143
|
+
const configuredOAuthLoginUrl = oauthLoginUrl || `${domainLogin.replace(/\/$/, '')}/oauth2/login`;
|
|
144
|
+
const configuredOAuthAuthorizeUrl = oauthAuthorizeUrl || `${domainLogin.replace(/\/$/, '')}/api/account/oauth-authenticate`;
|
|
145
|
+
const finishWithError = (error) => {
|
|
146
|
+
if (!oryFlowActive.current) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const code = error?.code || 'ORY_LOGIN_FAILED';
|
|
150
|
+
setOryError(describeOryFailure(code));
|
|
151
|
+
handleLoginFail({ code, message: error?.message });
|
|
152
|
+
};
|
|
153
|
+
let flow;
|
|
154
|
+
if (oryCallback) {
|
|
155
|
+
flow = completeOryAuthorization({
|
|
156
|
+
location: window.location,
|
|
157
|
+
tokenUrl: oauthTokenUrl || DEFAULT_OAUTH_TOKEN_URL,
|
|
158
|
+
clientId: oauthClientId,
|
|
159
|
+
redirectUri: oauthRedirectUri,
|
|
160
|
+
storageKey: oauthStorageKey,
|
|
161
|
+
}).then(async (tokenResponse) => {
|
|
162
|
+
if (!oryFlowActive.current) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (!onOAuthSuccess) {
|
|
166
|
+
const missingHandler = new Error('OAuth success handler is required');
|
|
167
|
+
missingHandler.code = 'ORY_SUCCESS_HANDLER_REQUIRED';
|
|
168
|
+
throw missingHandler;
|
|
169
|
+
}
|
|
170
|
+
return onOAuthSuccess(tokenResponse);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else if (oryBridgeRequest && explicitOry) {
|
|
174
|
+
flow = checkOrySession({ sessionUrl })
|
|
175
|
+
.then(() => {
|
|
176
|
+
if (!oryFlowActive.current)
|
|
177
|
+
return;
|
|
178
|
+
window.location.assign(getOAuthBridgeURL({
|
|
179
|
+
location: window.location,
|
|
180
|
+
oauthLoginUrl: configuredOAuthLoginUrl,
|
|
181
|
+
}));
|
|
182
|
+
})
|
|
183
|
+
.catch(error => {
|
|
184
|
+
if (error?.code === 'ORY_MFA_REQUIRED') {
|
|
185
|
+
if (oryFlowActive.current) {
|
|
186
|
+
setOryView('mfa');
|
|
187
|
+
setOryChallengeState('sign-in');
|
|
188
|
+
}
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
if (error?.status === 401 || error?.code === 'ORY_SESSION_REQUIRED') {
|
|
192
|
+
if (oryFlowActive.current)
|
|
193
|
+
setOryChallengeState('sign-in');
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
else if (oryBridgeRequest) {
|
|
200
|
+
flow = resolveOryLogin({
|
|
201
|
+
location: window.location,
|
|
202
|
+
oauthLoginUrl: configuredOAuthLoginUrl,
|
|
203
|
+
kratosLoginUrl,
|
|
204
|
+
sessionUrl,
|
|
205
|
+
assign: url => window.location.assign(url),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
else if (!onOAuthSuccess) {
|
|
209
|
+
const missingHandler = new Error('OAuth success handler is required');
|
|
210
|
+
missingHandler.code = 'ORY_SUCCESS_HANDLER_REQUIRED';
|
|
211
|
+
flow = Promise.reject(missingHandler);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
flow = startOryAuthorization({
|
|
215
|
+
location: window.location,
|
|
216
|
+
authorizeUrl: configuredOAuthAuthorizeUrl,
|
|
217
|
+
clientId: oauthClientId,
|
|
218
|
+
redirectUri: oauthRedirectUri,
|
|
219
|
+
scope: oauthScope,
|
|
220
|
+
audience: oauthAudience,
|
|
221
|
+
storageKey: oauthStorageKey,
|
|
222
|
+
assign: url => window.location.assign(url),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
flow.catch(finishWithError);
|
|
226
|
+
return () => {
|
|
227
|
+
oryFlowActive.current = false;
|
|
228
|
+
};
|
|
229
|
+
}, [
|
|
230
|
+
oryEnabled,
|
|
231
|
+
hasOAuthConfig,
|
|
232
|
+
oryCallback,
|
|
233
|
+
oryBridgeRequest,
|
|
234
|
+
oryPasswordForm,
|
|
235
|
+
oryConsentRequest,
|
|
236
|
+
oryChallengeState,
|
|
237
|
+
oauthLoginUrl,
|
|
238
|
+
oauthAuthorizeUrl,
|
|
239
|
+
oauthTokenUrl,
|
|
240
|
+
oauthClientId,
|
|
241
|
+
oauthRedirectUri,
|
|
242
|
+
oauthScope,
|
|
243
|
+
oauthAudience,
|
|
244
|
+
oauthStorageKey,
|
|
245
|
+
kratosLoginUrl,
|
|
246
|
+
sessionUrl,
|
|
247
|
+
onOAuthSuccess,
|
|
248
|
+
domainLogin,
|
|
249
|
+
oauthAutoStart,
|
|
250
|
+
]);
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
if (oryEnabled)
|
|
253
|
+
return;
|
|
254
|
+
if (searchParams.get('ui') === 'forgot') {
|
|
255
|
+
setStep(STEPS.STEP_FORGOT);
|
|
256
|
+
searchParams.delete('ui');
|
|
257
|
+
const newSearch = searchParams.toString();
|
|
258
|
+
history.pushState({}, '', `?${newSearch}`);
|
|
259
|
+
}
|
|
260
|
+
}, [searchParams, oryEnabled]);
|
|
261
|
+
const getObjectPropSafely = (fn, defaultValue) => {
|
|
262
|
+
try {
|
|
263
|
+
return fn();
|
|
264
|
+
}
|
|
265
|
+
catch (e) {
|
|
266
|
+
return defaultValue;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
const getMenuUrl = (menu, userId = '') => {
|
|
270
|
+
if (!menu || !menu.menu_path) {
|
|
271
|
+
return '';
|
|
272
|
+
}
|
|
273
|
+
const { app_domain: appDomain, app_path: appPath, menu_path: menuPath } = menu;
|
|
274
|
+
return (appDomain + appPath + menuPath).replace(/:user_id/g, userId);
|
|
275
|
+
};
|
|
276
|
+
const getNetworkInfo = (app_id) => fetch(`${domainLogin}api/network/info?app_id=${app_id}`)
|
|
277
|
+
.then(response => response.json())
|
|
278
|
+
.then(res => {
|
|
279
|
+
if (res?.data?.networkInfo?.logo) {
|
|
280
|
+
setUrlLogo(res.data.networkInfo.logo);
|
|
281
|
+
}
|
|
282
|
+
if (res?.data?.use_google_login && +res.data.use_google_login === 1) {
|
|
283
|
+
setIsLoginGG(true);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
if (networkId) {
|
|
288
|
+
getNetworkInfo(networkId);
|
|
289
|
+
}
|
|
290
|
+
}, [networkId]);
|
|
291
|
+
const getAppsMenus = ({ token, userId, accountId }, callback) => {
|
|
292
|
+
if (apiDomain && token && userId && accountId) {
|
|
293
|
+
const apiUrl = `${apiDomain}${usePrivilege ? '/api/privilege/index' : '/api/permission/index'}`;
|
|
294
|
+
axios({
|
|
295
|
+
url: apiUrl,
|
|
296
|
+
params: {
|
|
297
|
+
type: 'list-app',
|
|
298
|
+
_token: token,
|
|
299
|
+
_user_id: userId,
|
|
300
|
+
_account_id: accountId,
|
|
301
|
+
_lang: 'en',
|
|
302
|
+
hasChild: true,
|
|
303
|
+
from: 'login',
|
|
304
|
+
},
|
|
305
|
+
}).then(res => {
|
|
306
|
+
callback(res);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
const getListAccountSharing = ({ token, userId, accountId }) => {
|
|
311
|
+
const params = {
|
|
312
|
+
type: 'get-list-access',
|
|
313
|
+
_token: token,
|
|
314
|
+
_user_id: userId,
|
|
315
|
+
_account_id: accountId,
|
|
316
|
+
_lang: 'en',
|
|
317
|
+
limit: 1000,
|
|
318
|
+
search: '',
|
|
319
|
+
};
|
|
320
|
+
return axios.get(`${apiDomain}/api/account/share-access`, { params });
|
|
321
|
+
};
|
|
322
|
+
const redirectFirstMenuAccount = async (redirectAccountId, token) => {
|
|
323
|
+
if (!redirectAccountId) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
axios
|
|
327
|
+
.get(`${apiDomain}/api/privilege/index`, {
|
|
328
|
+
params: {
|
|
329
|
+
_token: token,
|
|
330
|
+
_user_id: redirectAccountId,
|
|
331
|
+
_account_id: redirectAccountId,
|
|
332
|
+
_lang: 'en',
|
|
333
|
+
hasChild: true,
|
|
334
|
+
type: 'list-app',
|
|
335
|
+
from: 'header',
|
|
336
|
+
},
|
|
337
|
+
})
|
|
338
|
+
.then(res => {
|
|
339
|
+
if (res && res.data) {
|
|
340
|
+
redirectFirstMenu(res.data.data, redirectAccountId);
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
const redirectFirstMenu = (data, redirectAccountId) => {
|
|
345
|
+
if (!Array.isArray(data)) {
|
|
346
|
+
return false;
|
|
347
|
+
}
|
|
348
|
+
const arrMenus = getObjectPropSafely(() => [...data].sort((first, second) => first.app_order - second.app_order)[0].childs, []);
|
|
349
|
+
if (arrMenus.length) {
|
|
350
|
+
const firstMenu = arrMenus
|
|
351
|
+
.filter(menu => +menu.show_hide)
|
|
352
|
+
.sort((first, second) => first.menu_order - second.menu_order)[0];
|
|
353
|
+
if (firstMenu) {
|
|
354
|
+
const redirectUrl = getMenuUrl(firstMenu, redirectAccountId);
|
|
355
|
+
navigateTo(redirectUrl);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const checkRedirectHomePage = (homePage, data, userId) => {
|
|
360
|
+
const convertedHomePage = String(homePage).replace(/:user_id/g, userId || '');
|
|
361
|
+
if (!Array.isArray(data) || !data.length) {
|
|
362
|
+
return navigateTo(convertedHomePage);
|
|
363
|
+
}
|
|
364
|
+
const arrMenus = buildListAppMenus(data, userId);
|
|
365
|
+
if (!arrMenus.some(url => convertedHomePage.includes(url))) {
|
|
366
|
+
return redirectFirstMenu(data, userId);
|
|
367
|
+
}
|
|
368
|
+
navigateTo(convertedHomePage);
|
|
369
|
+
};
|
|
370
|
+
const buildListAppMenus = (data, userId) => {
|
|
371
|
+
if (!Array.isArray(data) || !data.length) {
|
|
372
|
+
return [];
|
|
373
|
+
}
|
|
374
|
+
let arrMenus = [];
|
|
375
|
+
data.forEach(item => {
|
|
376
|
+
if (item.menu_id) {
|
|
377
|
+
arrMenus.push(getMenuUrl(item, userId));
|
|
378
|
+
}
|
|
379
|
+
if (item.childs && item.childs.length) {
|
|
380
|
+
arrMenus = arrMenus.concat(buildListAppMenus(item.childs, userId));
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
return arrMenus;
|
|
384
|
+
};
|
|
385
|
+
const handleLoginSuccess = (data = null, networkRedirect = null, accountRedirect = null) => {
|
|
386
|
+
// check setup loading skip
|
|
387
|
+
if (data && data.isCheckSkip) {
|
|
388
|
+
setLoadingSkip(true);
|
|
389
|
+
}
|
|
390
|
+
if (data && data.isCheckG2FA && data.G2FA === 1) {
|
|
391
|
+
setLoginData(data);
|
|
392
|
+
setStep(STEPS.STEP_CHOOSE_METHOD);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
const dataLogin = data || loginData;
|
|
396
|
+
if (accountRedirect) {
|
|
397
|
+
return redirectFirstMenuAccount(accountRedirect.user_id, dataLogin.token);
|
|
398
|
+
}
|
|
399
|
+
let isCallbackUrl = false;
|
|
400
|
+
let isHomePageUrl = false;
|
|
401
|
+
if (callbackUrl && checkURL(callbackUrl)) {
|
|
402
|
+
isCallbackUrl = true;
|
|
403
|
+
}
|
|
404
|
+
if (selectedNetworkRef.current && selectedNetworkRef.current.homePage) {
|
|
405
|
+
isHomePageUrl = true;
|
|
406
|
+
}
|
|
407
|
+
if (networkId || selectedNetworkRef.current) {
|
|
408
|
+
if ((onLoginSuccess && typeof onLoginSuccess === 'function') ||
|
|
409
|
+
isCallbackUrl ||
|
|
410
|
+
isHomePageUrl ||
|
|
411
|
+
networkRedirect ||
|
|
412
|
+
selectedNetworkRef.current) {
|
|
413
|
+
if (apiDomain) {
|
|
414
|
+
getAppsMenus({
|
|
415
|
+
token: dataLogin.token,
|
|
416
|
+
userId: dataLogin?.personal?.user_id,
|
|
417
|
+
accountId: dataLogin?.personal?.user_id,
|
|
418
|
+
}, res => {
|
|
419
|
+
const menus = getObjectPropSafely(() => res.data.data, []);
|
|
420
|
+
if (menus && menus.length) {
|
|
421
|
+
handleLoginData(dataLogin, !isCallbackUrl && !isHomePageUrl, selectedNetworkRef.current && selectedNetworkRef.current.networkId);
|
|
422
|
+
if (onLoginSuccess && typeof onLoginSuccess === 'function') {
|
|
423
|
+
onLoginSuccess({
|
|
424
|
+
...dataLogin,
|
|
425
|
+
networkId: selectedNetworkRef.current?.networkId ?? networkId,
|
|
426
|
+
});
|
|
427
|
+
setLoadingSkip(false);
|
|
428
|
+
}
|
|
429
|
+
else if (isCallbackUrl && callbackUrl) {
|
|
430
|
+
navigateTo(callbackUrl);
|
|
431
|
+
setLoadingSkip(false);
|
|
432
|
+
}
|
|
433
|
+
else if (isHomePageUrl) {
|
|
434
|
+
checkRedirectHomePage(selectedNetworkRef.current?.homePage, menus, dataLogin.personal?.user_id);
|
|
435
|
+
setLoadingSkip(false);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
// Get user share
|
|
440
|
+
getListAccountSharing({
|
|
441
|
+
token: dataLogin.token,
|
|
442
|
+
userId: dataLogin.personal?.user_id,
|
|
443
|
+
accountId: dataLogin.personal?.user_id,
|
|
444
|
+
}).then(res => {
|
|
445
|
+
if (getObjectPropSafely(() => res.data.data.list_access.length, 0) &&
|
|
446
|
+
res.data.data.list_access.some(account => account.user_id.toString() !== dataLogin.personal?.user_id.toString())) {
|
|
447
|
+
handleLoginData(dataLogin, false, selectedNetworkRef.current && selectedNetworkRef.current.networkId);
|
|
448
|
+
if (data) {
|
|
449
|
+
setLoginData(data);
|
|
450
|
+
}
|
|
451
|
+
listAccountsRef.current = getObjectPropSafely(() => res.data.data.list_access.filter(account => account.user_id.toString() !== dataLogin.personal?.user_id.toString()), 0);
|
|
452
|
+
setStep(STEPS.STEP_SELECT_ACCOUNT);
|
|
453
|
+
setLoadingSkip(false);
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
// No menu, no share access, just redirect to home page
|
|
457
|
+
handleLoginData(dataLogin, !isCallbackUrl && !isHomePageUrl, selectedNetworkRef.current && selectedNetworkRef.current.networkId);
|
|
458
|
+
setLoadingSkip(false);
|
|
459
|
+
if (onLoginSuccess && typeof onLoginSuccess === 'function') {
|
|
460
|
+
onLoginSuccess({
|
|
461
|
+
...dataLogin,
|
|
462
|
+
networkId: selectedNetworkRef.current?.networkId ?? networkId,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
else if (isCallbackUrl && callbackUrl) {
|
|
466
|
+
navigateTo(callbackUrl);
|
|
467
|
+
}
|
|
468
|
+
else if (isHomePageUrl) {
|
|
469
|
+
navigateTo(selectedNetworkRef.current?.homePage);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
// if (res && res.data && res.data.data && res.data.data.length) {
|
|
474
|
+
// const appData = res.data.data
|
|
475
|
+
// setApps(appData)
|
|
476
|
+
// }
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
setLoadingSkip(false);
|
|
482
|
+
handleLoginData(dataLogin, !isCallbackUrl && !isHomePageUrl, selectedNetworkRef.current && selectedNetworkRef.current.networkId);
|
|
483
|
+
if (onLoginSuccess && typeof onLoginSuccess === 'function') {
|
|
484
|
+
onLoginSuccess({
|
|
485
|
+
...dataLogin,
|
|
486
|
+
networkId: selectedNetworkRef.current?.networkId ?? networkId,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
else if (isCallbackUrl && callbackUrl) {
|
|
490
|
+
navigateTo(callbackUrl);
|
|
491
|
+
}
|
|
492
|
+
else if (isHomePageUrl) {
|
|
493
|
+
navigateTo(selectedNetworkRef.current?.homePage);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
setLoadingSkip(false);
|
|
499
|
+
if (data) {
|
|
500
|
+
setLoginData(data);
|
|
501
|
+
}
|
|
502
|
+
getListNetworkSelect(dataLogin.token, networkId);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
setLoadingSkip(false);
|
|
507
|
+
if (data) {
|
|
508
|
+
setLoginData(data);
|
|
509
|
+
}
|
|
510
|
+
getListNetworkSelect(dataLogin.token);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
const loginNetworkWithToken = async (token, networkItem, networkRedirect = null) => {
|
|
515
|
+
if (!token || !networkItem || !networkItem.networkId) {
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
selectedNetworkRef.current = networkItem;
|
|
519
|
+
const { networkId: networkIdSelected } = networkItem;
|
|
520
|
+
const data = {
|
|
521
|
+
token,
|
|
522
|
+
app_id: networkIdSelected,
|
|
523
|
+
};
|
|
524
|
+
setLoading(true);
|
|
525
|
+
const xhr = new XMLHttpRequest();
|
|
526
|
+
xhr.open('POST', loginUrl, true);
|
|
527
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
528
|
+
xhr.withCredentials = false;
|
|
529
|
+
xhr.onreadystatechange = () => {
|
|
530
|
+
setLoading(false);
|
|
531
|
+
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
|
532
|
+
const response = JSON.parse(xhr.responseText);
|
|
533
|
+
if (response?.data?.token) {
|
|
534
|
+
handleLoginSuccess(response.data, networkRedirect);
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
handleLoginFail();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
xhr.send(JSON.stringify(data));
|
|
542
|
+
};
|
|
543
|
+
const getListNetworkSelect = (token, networkRedirect = '') => {
|
|
544
|
+
if (selectedNetworkRef.current && selectedNetworkRef.current.networkId) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (token) {
|
|
548
|
+
setLoading(true);
|
|
549
|
+
fetch(`${domainLogin}api/network/info?type=get-list-network&token=${token}`)
|
|
550
|
+
.then(response => response.json())
|
|
551
|
+
.then(res => {
|
|
552
|
+
if (res?.data?.length) {
|
|
553
|
+
listNetworkRef.current = res.data.map((network) => ({
|
|
554
|
+
networkId: network.network_id,
|
|
555
|
+
networkName: network.network_name,
|
|
556
|
+
homePage: network.home_page,
|
|
557
|
+
logo: network.logo,
|
|
558
|
+
}));
|
|
559
|
+
if (!res.data.length) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (networkRedirect) {
|
|
563
|
+
const redirectNetwork = res.data.find((network) => +network.network_id === +networkRedirect);
|
|
564
|
+
if (redirectNetwork) {
|
|
565
|
+
loginNetworkWithToken(token, {
|
|
566
|
+
networkId: redirectNetwork.network_id,
|
|
567
|
+
networkName: redirectNetwork.network_name,
|
|
568
|
+
homePage: redirectNetwork.home_page,
|
|
569
|
+
logo: redirectNetwork.logo,
|
|
570
|
+
}, networkRedirect);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
if (res.data.length > 1) {
|
|
574
|
+
setStep(STEPS.STEP_SELECT_NETWORK);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
loginNetworkWithToken(token, {
|
|
578
|
+
networkId: res.data[0].network_id,
|
|
579
|
+
networkName: res.data[0].network_name,
|
|
580
|
+
homePage: res.data[0].home_page,
|
|
581
|
+
logo: res.data[0].logo,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
if (res.data.length > 1) {
|
|
588
|
+
setStep(STEPS.STEP_SELECT_NETWORK);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
loginNetworkWithToken(token, {
|
|
592
|
+
networkId: res.data[0].network_id,
|
|
593
|
+
networkName: res.data[0].network_name,
|
|
594
|
+
homePage: res.data[0].home_page,
|
|
595
|
+
logo: res.data[0].logo,
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
})
|
|
601
|
+
.finally(() => {
|
|
602
|
+
setLoading(false);
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
const callbackSelectNetwork = (networkItem) => {
|
|
607
|
+
loginNetworkWithToken(loginData.token, networkItem);
|
|
608
|
+
};
|
|
609
|
+
const handleLoginFail = (data) => {
|
|
610
|
+
if (data?.code) {
|
|
611
|
+
switch (data.code) {
|
|
612
|
+
case 106:
|
|
613
|
+
setStep(STEPS.STEP_VERIFY_ACCOUNT);
|
|
614
|
+
break;
|
|
615
|
+
default:
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (onLoginFail && typeof onLoginFail === 'function') {
|
|
620
|
+
onLoginFail(data);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
const onSetupGGAuthenticatorDone = () => {
|
|
624
|
+
setStep(STEPS.STEP_LOGIN_WITH_GG);
|
|
625
|
+
};
|
|
626
|
+
const onSkipSetupGGAuthenticator = () => {
|
|
627
|
+
handleLoginSuccess({
|
|
628
|
+
...(loginData || {}),
|
|
629
|
+
isCheckG2FA: false,
|
|
630
|
+
isCheckSkip: true,
|
|
631
|
+
});
|
|
632
|
+
};
|
|
633
|
+
const onForgotPassword = () => {
|
|
634
|
+
setStep(STEPS.STEP_FORGOT);
|
|
635
|
+
};
|
|
636
|
+
const onResendSuccess = () => {
|
|
637
|
+
setStep(STEPS.STEP_FORGOT_RESEND);
|
|
638
|
+
};
|
|
639
|
+
const backLogin = () => {
|
|
640
|
+
selectedNetworkRef.current = null;
|
|
641
|
+
setLoginData({});
|
|
642
|
+
authenInfoRef.current = null;
|
|
643
|
+
setStep(STEPS.STEP1);
|
|
644
|
+
};
|
|
645
|
+
const setAuthenInfo = (info) => (authenInfoRef.current = info);
|
|
646
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
647
|
+
window['popupCallbackLoginUser'] = function (data) {
|
|
648
|
+
postMessage(data);
|
|
649
|
+
};
|
|
650
|
+
const postMessage = (postParam, doPostEvent = true) => {
|
|
651
|
+
if (postParam.error && postParam.error !== '') {
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
if (postParam.action === 'ogs-authenticate') {
|
|
655
|
+
const loginData = { ...postParam, type: 'all_account' };
|
|
656
|
+
if (loginData.hasOwnProperty('full_name')) {
|
|
657
|
+
delete loginData.full_name;
|
|
658
|
+
}
|
|
659
|
+
if (loginData.hasOwnProperty('email')) {
|
|
660
|
+
delete loginData.email;
|
|
661
|
+
}
|
|
662
|
+
if (loginData.hasOwnProperty('avatar')) {
|
|
663
|
+
delete loginData.avatar;
|
|
664
|
+
}
|
|
665
|
+
if (loginData.hasOwnProperty('action')) {
|
|
666
|
+
delete loginData.action;
|
|
667
|
+
}
|
|
668
|
+
if (loginData.hasOwnProperty('env')) {
|
|
669
|
+
delete loginData.env;
|
|
670
|
+
}
|
|
671
|
+
if (u_ogs && typeof u_ogs === 'string' && u_ogs.trim()) {
|
|
672
|
+
const replaceNetwork = getObjectPropSafely(() => selectedNetworkRef.current?.networkId || 0, networkId);
|
|
673
|
+
const cookieKey = u_ogs.includes(replaceNetwork)
|
|
674
|
+
? u_ogs
|
|
675
|
+
: `${u_ogs}_${selectedNetworkRef.current?.networkId}`;
|
|
676
|
+
const maxAge = 30 * 24 * 3600;
|
|
677
|
+
const cookieOptions = createCrossSubdomainCookieOptions({
|
|
678
|
+
hostname: window.location.hostname,
|
|
679
|
+
protocol: window.location.protocol,
|
|
680
|
+
maxAge,
|
|
681
|
+
});
|
|
682
|
+
setCookie(cookieKey, JSON.stringify(loginData), cookieOptions);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (doPostEvent) {
|
|
686
|
+
if (parent && parent.postMessage) {
|
|
687
|
+
parent.postMessage(JSON.stringify(postParam), '*');
|
|
688
|
+
}
|
|
689
|
+
else {
|
|
690
|
+
postMessage(JSON.stringify(postParam), '*');
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
const handleLoginData = (data = null, doPostEvent = true, doSelectNetwork) => {
|
|
696
|
+
data = data || loginData;
|
|
697
|
+
if (!data.token) {
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
if (data && data.personal) {
|
|
701
|
+
localStorage.setItem('user_logged_in_full_name', data.personal.full_name);
|
|
702
|
+
localStorage.setItem('user_logged_in_avatar', data.personal.avatar);
|
|
703
|
+
localStorage.setItem('user_logged_in_email', data.personal.email);
|
|
704
|
+
}
|
|
705
|
+
if (u_ogs && typeof u_ogs === 'string' && u_ogs.trim()) {
|
|
706
|
+
const userData = {};
|
|
707
|
+
Object.assign(userData, data.personal);
|
|
708
|
+
if (userData.hasOwnProperty('full_name')) {
|
|
709
|
+
delete userData.full_name;
|
|
710
|
+
}
|
|
711
|
+
if (userData.hasOwnProperty('email')) {
|
|
712
|
+
delete userData.email;
|
|
713
|
+
}
|
|
714
|
+
if (userData.hasOwnProperty('avatar')) {
|
|
715
|
+
delete userData.avatar;
|
|
716
|
+
}
|
|
717
|
+
if (userData.hasOwnProperty('action')) {
|
|
718
|
+
delete userData.action;
|
|
719
|
+
}
|
|
720
|
+
userData.token = data.token;
|
|
721
|
+
}
|
|
722
|
+
const postParam = {
|
|
723
|
+
action: 'ogs-authenticate',
|
|
724
|
+
user_id: data?.personal?.user_id,
|
|
725
|
+
account_id: data?.personal?.user_id,
|
|
726
|
+
full_name: data?.personal?.full_name,
|
|
727
|
+
role: data?.personal?.role,
|
|
728
|
+
seller_role: data?.personal?.seller_role,
|
|
729
|
+
conversion_id: data?.personal?.conversion_id,
|
|
730
|
+
email: data?.personal?.email,
|
|
731
|
+
avatar: data?.personal?.avatar,
|
|
732
|
+
token: data?.token,
|
|
733
|
+
language: data?.personal?.language,
|
|
734
|
+
};
|
|
735
|
+
postMessage(postParam, doPostEvent);
|
|
736
|
+
postMessage(postParam, doPostEvent);
|
|
737
|
+
};
|
|
738
|
+
const handleSelectAccount = (account) => {
|
|
739
|
+
if (account && account.user_id) {
|
|
740
|
+
handleLoginSuccess(null, null, account);
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
const sendMailValidateAccount = async (callback) => {
|
|
744
|
+
if (!authenInfoRef.current || !authenInfoRef.current.email) {
|
|
745
|
+
return callback(null);
|
|
746
|
+
}
|
|
747
|
+
const loginUrl = `${domainLogin}account/resend-verify-account`;
|
|
748
|
+
const { email } = authenInfoRef.current;
|
|
749
|
+
const loginData = {
|
|
750
|
+
user_name: email,
|
|
751
|
+
app_id: networkId,
|
|
752
|
+
};
|
|
753
|
+
setLoading(true);
|
|
754
|
+
const xhr = new XMLHttpRequest();
|
|
755
|
+
xhr.open('POST', loginUrl, true);
|
|
756
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
757
|
+
xhr.withCredentials = false;
|
|
758
|
+
xhr.onreadystatechange = () => {
|
|
759
|
+
setLoading(false);
|
|
760
|
+
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
|
761
|
+
const response = JSON.parse(xhr.responseText);
|
|
762
|
+
const { data } = response;
|
|
763
|
+
if (callback && typeof callback === 'function') {
|
|
764
|
+
callback(data || response);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
xhr.send(JSON.stringify(loginData));
|
|
769
|
+
};
|
|
770
|
+
const sendCodeVerifyToEmail = async () => {
|
|
771
|
+
if (!authenInfoRef.current || !authenInfoRef.current.email) {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
const loginUrl = `${domainLogin}api/account/send-email-code`;
|
|
775
|
+
const data = {
|
|
776
|
+
token: loginData.token,
|
|
777
|
+
};
|
|
778
|
+
setLoading(true);
|
|
779
|
+
const xhr = new XMLHttpRequest();
|
|
780
|
+
xhr.open('POST', loginUrl, true);
|
|
781
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
782
|
+
xhr.withCredentials = false;
|
|
783
|
+
xhr.onreadystatechange = () => {
|
|
784
|
+
setLoading(false);
|
|
785
|
+
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
|
786
|
+
const response = JSON.parse(xhr.responseText);
|
|
787
|
+
const { data, code } = response;
|
|
788
|
+
if (code !== 200) {
|
|
789
|
+
setLoginData({
|
|
790
|
+
...loginData,
|
|
791
|
+
errorCode: data.error,
|
|
792
|
+
retryAfter: data.retryAfter,
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
xhr.send(JSON.stringify(data));
|
|
798
|
+
};
|
|
799
|
+
const onChooseMethod = (method) => {
|
|
800
|
+
switch (method) {
|
|
801
|
+
case LOGIN_METHODS.GOOGLE_AUTHENTICATOR:
|
|
802
|
+
setStep(STEPS.STEP_LOGIN_WITH_GG);
|
|
803
|
+
break;
|
|
804
|
+
case LOGIN_METHODS.EMAIL:
|
|
805
|
+
sendCodeVerifyToEmail();
|
|
806
|
+
setStep(STEPS.STEP_LOGIN_WITH_EMAIL);
|
|
807
|
+
break;
|
|
808
|
+
default:
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
const { width } = useContainerDimensions(loginRef);
|
|
813
|
+
const scaleCaptcha = useMemo(() => +((+width * 1.02) / 400).toFixed(2), [width]);
|
|
814
|
+
const errorCodeSend = get(loginData, 'errorCode', '');
|
|
815
|
+
const retryAfter = get(loginData, 'retryAfter');
|
|
816
|
+
const step1Config = {
|
|
817
|
+
domainLogin,
|
|
818
|
+
networkId,
|
|
819
|
+
u_ogs,
|
|
820
|
+
urlLogo,
|
|
821
|
+
isLoginGG,
|
|
822
|
+
callbackUrl,
|
|
823
|
+
loadingNetwork: isLoading,
|
|
824
|
+
handleLoginData,
|
|
825
|
+
setAuthenInfo,
|
|
826
|
+
onForgotPassword: oryEnabled
|
|
827
|
+
? oryPasswordForm
|
|
828
|
+
? () => setOryView('recovery')
|
|
829
|
+
: undefined
|
|
830
|
+
: onForgotPassword,
|
|
831
|
+
onLoginSuccess: handleLoginSuccess,
|
|
832
|
+
onOrySubmit: oryPasswordForm ? handleOryPasswordSubmit : undefined,
|
|
833
|
+
onLoginFail: handleLoginFail,
|
|
834
|
+
};
|
|
835
|
+
const step2Config = {
|
|
836
|
+
domainLogin,
|
|
837
|
+
token: loginData.token || '',
|
|
838
|
+
username: get(loginData, 'personal.email') || '',
|
|
839
|
+
userId: get(loginData, 'personal.user_id') || 0,
|
|
840
|
+
urlLogo,
|
|
841
|
+
loginData,
|
|
842
|
+
handleLoginData,
|
|
843
|
+
onLoginSuccess: handleLoginSuccess,
|
|
844
|
+
backLogin,
|
|
845
|
+
onLoginFail: handleLoginFail,
|
|
846
|
+
onSetupGGAuthenticatorDone,
|
|
847
|
+
onSkipSetupGGAuthenticator,
|
|
848
|
+
loadingSkip: isLoadingSkip,
|
|
849
|
+
};
|
|
850
|
+
const stepChooseMethodConfig = {
|
|
851
|
+
domainLogin,
|
|
852
|
+
token: loginData.token || '',
|
|
853
|
+
username: get(loginData, 'personal.email') || '',
|
|
854
|
+
userId: get(loginData, 'personal.user_id') || 0,
|
|
855
|
+
urlLogo,
|
|
856
|
+
loginData,
|
|
857
|
+
backLogin,
|
|
858
|
+
onChooseMethod,
|
|
859
|
+
};
|
|
860
|
+
const stepVerifyWithEmailConfig = {
|
|
861
|
+
...stepChooseMethodConfig,
|
|
862
|
+
sendCodeVerifyToEmail,
|
|
863
|
+
onLoginSuccess: handleLoginSuccess,
|
|
864
|
+
onLoginFail: handleLoginFail,
|
|
865
|
+
};
|
|
866
|
+
const forgotConfig = {
|
|
867
|
+
domainLogin,
|
|
868
|
+
networkId,
|
|
869
|
+
reCaptchaKey,
|
|
870
|
+
p_id,
|
|
871
|
+
urlLogo,
|
|
872
|
+
callbackUrl,
|
|
873
|
+
onResendSuccess,
|
|
874
|
+
backLogin,
|
|
875
|
+
onResendFail: onResendPassFail,
|
|
876
|
+
scaleCaptcha,
|
|
877
|
+
};
|
|
878
|
+
const stepSelectNetworkConfig = {
|
|
879
|
+
domainLogin,
|
|
880
|
+
networkId,
|
|
881
|
+
u_ogs,
|
|
882
|
+
urlLogo,
|
|
883
|
+
isLoginGG,
|
|
884
|
+
callbackUrl,
|
|
885
|
+
loginData: {
|
|
886
|
+
...loginData,
|
|
887
|
+
personal: loginData.personal || {
|
|
888
|
+
avatar: '',
|
|
889
|
+
full_name: '',
|
|
890
|
+
email: '',
|
|
891
|
+
user_id: '',
|
|
892
|
+
},
|
|
893
|
+
},
|
|
894
|
+
listNetworks: listNetworkRef.current,
|
|
895
|
+
callbackSelectNetwork,
|
|
896
|
+
handleLoginData,
|
|
897
|
+
backLogin,
|
|
898
|
+
onForgotPassword,
|
|
899
|
+
onLoginSuccess: handleLoginSuccess,
|
|
900
|
+
onLoginFail: handleLoginFail,
|
|
901
|
+
};
|
|
902
|
+
const stepVerifyAccount = {
|
|
903
|
+
domainLogin,
|
|
904
|
+
networkId,
|
|
905
|
+
u_ogs,
|
|
906
|
+
urlLogo,
|
|
907
|
+
isLoginGG,
|
|
908
|
+
callbackUrl,
|
|
909
|
+
loginData,
|
|
910
|
+
listNetworks: listNetworkRef.current,
|
|
911
|
+
callbackSelectNetwork,
|
|
912
|
+
handleLoginData,
|
|
913
|
+
onForgotPassword,
|
|
914
|
+
onLoginSuccess: handleLoginSuccess,
|
|
915
|
+
onLoginFail: handleLoginFail,
|
|
916
|
+
authenInfo: authenInfoRef.current,
|
|
917
|
+
backLogin,
|
|
918
|
+
sendMailValidateAccount,
|
|
919
|
+
};
|
|
920
|
+
const renderMain = () => {
|
|
921
|
+
switch (step) {
|
|
922
|
+
case STEPS.STEP1:
|
|
923
|
+
return _jsx(SignIn, { ...step1Config });
|
|
924
|
+
case STEPS.STEP_CHOOSE_METHOD:
|
|
925
|
+
return _jsx(ChooseMethod, { ...stepChooseMethodConfig });
|
|
926
|
+
case STEPS.STEP_LOGIN_WITH_EMAIL:
|
|
927
|
+
return _jsx(LoginWithEmail, { ...stepVerifyWithEmailConfig });
|
|
928
|
+
case STEPS.STEP_LOGIN_WITH_GG:
|
|
929
|
+
return _jsx(LoginWithGG, { ...step2Config });
|
|
930
|
+
case STEPS.STEP_SELECT_NETWORK:
|
|
931
|
+
return _jsx(LoginSelectPortal, { ...stepSelectNetworkConfig });
|
|
932
|
+
case STEPS.STEP_SETUP_GG_AUTHENTICATOR:
|
|
933
|
+
return _jsx(SetupGGAuthenticator, { ...step2Config });
|
|
934
|
+
case STEPS.STEP_VERIFY_ACCOUNT:
|
|
935
|
+
return _jsx(VerifyAccount, { ...stepVerifyAccount });
|
|
936
|
+
default:
|
|
937
|
+
return _jsx(ForgotPassword, { ...forgotConfig });
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
// The portal and consent screens are full pages, not part of the 404px login column.
|
|
941
|
+
if (oryConsentRequest) {
|
|
942
|
+
return (_jsx(OryThemeProvider, { children: _jsx(OryConsent, { consentUrl: oauthConsentUrl, csrfUrl: oauthCsrfUrl, sessionUrl: sessionUrl, scopeCatalog: oauthScopeCatalog, preview: oauthConsentPreview, onCancel: () => {
|
|
943
|
+
window.sessionStorage.removeItem(oauthStorageKey || DEFAULT_OAUTH_STORAGE_KEY);
|
|
944
|
+
window.location.assign(oauthRedirectUri || window.location.pathname);
|
|
945
|
+
}, onSwitchAccount: () => startOryLogout({
|
|
946
|
+
location: window.location,
|
|
947
|
+
returnTo: oauthRedirectUri || `${window.location.origin}${window.location.pathname}`,
|
|
948
|
+
kratosLogoutUrl,
|
|
949
|
+
assign: url => window.location.assign(url),
|
|
950
|
+
}) }) }));
|
|
951
|
+
}
|
|
952
|
+
const loginTree = (_jsx(CookiesProvider, { children: _jsxs(LoginMain, { justify: isMobile ? 'center' : 'start', id: "login_container", children: [_jsx(WrapperLogin, { isMobile: isMobile, vertical: true, align: "center", gap: 40, flex: 1, ref: loginRef, id: "login_main", children: oryEnabled && !oryPasswordForm ? (_jsx(OryStatus, { error: oryError, onRetry: restartOryFlow })) : oryPasswordForm && oryView === 'mfa' ? (_jsx(OryMfa, { kratosLoginUrl: kratosLoginUrl, sessionUrl: sessionUrl, onVerified: continueAfterMfa, onBack: () => setOryView('password') })) : oryPasswordForm && oryView === 'recovery' ? (_jsx(OryRecovery, { kratosRecoveryUrl: kratosRecoveryUrl, initialFlowId: oryRecoveryRequest ? searchParams.get('flow') || undefined : undefined, onBack: () => oryRecoveryRequest
|
|
953
|
+
? window.location.assign(`${window.location.origin}/login`)
|
|
954
|
+
: setOryView('password') })) : (renderMain()) }), !isMobile && _jsx(LoginBannerZone, { className: "login-banner-zone", id: "login_banner_zone" })] }) }));
|
|
955
|
+
// Ory mode is opt-in, so the legacy login keeps the host's own theme.
|
|
956
|
+
return explicitOry ? _jsx(OryThemeProvider, { children: loginTree }) : loginTree;
|
|
957
|
+
};
|