-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Wave Collect][Xero] Enforce 2FA for xero #44059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6532961
d68cb2c
8329d45
2481d2a
0e7cc39
0a19025
f710a3e
cfcc93b
fb58fad
c844340
5799a37
8cf4612
3c3a4d4
ccd36a5
04e5d53
45c9812
d527edf
a338137
e0dc00b
96ffb8e
1f4e9f1
beae97b
fe7efba
9873c32
b7feae6
e1f5e13
8d9b210
6d5c025
8a6ac29
4e02d3b
9fcd2f0
9aa057d
bd51726
d3819a5
6f46e17
626c154
a7bdb92
02670d3
74d03d0
859cf4a
57e752e
2290a74
c4da238
dcddaa2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,14 +1,19 @@ | ||||||
import React, {useState} from 'react'; | ||||||
import {useOnyx} from 'react-native-onyx'; | ||||||
import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal'; | ||||||
import Button from '@components/Button'; | ||||||
import RequireTwoFactorAuthenticationModal from '@components/RequireTwoFactorAuthenticationModal'; | ||||||
import useEnvironment from '@hooks/useEnvironment'; | ||||||
import useLocalize from '@hooks/useLocalize'; | ||||||
import useNetwork from '@hooks/useNetwork'; | ||||||
import useThemeStyles from '@hooks/useThemeStyles'; | ||||||
import {removePolicyConnection} from '@libs/actions/connections'; | ||||||
import {getXeroSetupLink} from '@libs/actions/connections/ConnectToXero'; | ||||||
import Navigation from '@libs/Navigation/Navigation'; | ||||||
import * as Link from '@userActions/Link'; | ||||||
import CONST from '@src/CONST'; | ||||||
import ONYXKEYS from '@src/ONYXKEYS'; | ||||||
import ROUTES from '@src/ROUTES'; | ||||||
import type {ConnectToXeroButtonProps} from './types'; | ||||||
|
||||||
function ConnectToXeroButton({policyID, shouldDisconnectIntegrationBeforeConnecting, integrationToDisconnect}: ConnectToXeroButtonProps) { | ||||||
|
@@ -17,12 +22,21 @@ function ConnectToXeroButton({policyID, shouldDisconnectIntegrationBeforeConnect | |||||
const {environmentURL} = useEnvironment(); | ||||||
const {isOffline} = useNetwork(); | ||||||
|
||||||
const [account] = useOnyx(ONYXKEYS.ACCOUNT); | ||||||
const is2FAEnabled = account?.requiresTwoFactorAuth; | ||||||
|
||||||
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false); | ||||||
const [isRequire2FAModalOpen, setIsRequire2FAModalOpen] = useState(false); | ||||||
|
||||||
return ( | ||||||
<> | ||||||
<Button | ||||||
onPress={() => { | ||||||
if (!is2FAEnabled) { | ||||||
setIsRequire2FAModalOpen(true); | ||||||
return; | ||||||
} | ||||||
|
||||||
if (shouldDisconnectIntegrationBeforeConnecting && integrationToDisconnect) { | ||||||
setIsDisconnectModalOpen(true); | ||||||
return; | ||||||
|
@@ -45,6 +59,18 @@ function ConnectToXeroButton({policyID, shouldDisconnectIntegrationBeforeConnect | |||||
onCancel={() => setIsDisconnectModalOpen(false)} | ||||||
/> | ||||||
)} | ||||||
{isRequire2FAModalOpen && ( | ||||||
<RequireTwoFactorAuthenticationModal | ||||||
onSubmit={() => { | ||||||
setIsRequire2FAModalOpen(false); | ||||||
Navigation.dismissModal(); | ||||||
Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.POLICY_ACCOUNTING.getRoute(policyID), getXeroSetupLink(policyID))); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think for narrow layout, another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not convinced by this? @rushatgabhane There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @c3024 sorry, let me give this a try There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this works well! thank you |
||||||
}} | ||||||
onCancel={() => setIsRequire2FAModalOpen(false)} | ||||||
isVisible | ||||||
description={translate('twoFactorAuth.twoFactorAuthIsRequiredDescription')} | ||||||
/> | ||||||
)} | ||||||
</> | ||||||
); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import CONST from '@src/CONST'; | ||
import Button from './Button'; | ||
import Lottie from './Lottie'; | ||
import LottieAnimations from './LottieAnimations'; | ||
import Modal from './Modal'; | ||
import SafeAreaConsumer from './SafeAreaConsumer'; | ||
import Text from './Text'; | ||
|
||
type RequireTwoFactorAuthenticationModalProps = { | ||
/** A callback to call when the form has been submitted */ | ||
onSubmit: () => void; | ||
|
||
/** A callback to call when the form has been closed */ | ||
onCancel?: () => void; | ||
|
||
/** Modal visibility */ | ||
isVisible: boolean; | ||
|
||
/** Describe what is showing */ | ||
description: string; | ||
|
||
/** | ||
* Whether the modal should enable the new focus manager. | ||
* We are attempting to migrate to a new refocus manager, adding this property for gradual migration. | ||
* */ | ||
shouldEnableNewFocusManagement?: boolean; | ||
}; | ||
|
||
function RequireTwoFactorAuthenticationModal({onCancel = () => {}, description, isVisible, onSubmit, shouldEnableNewFocusManagement}: RequireTwoFactorAuthenticationModalProps) { | ||
const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const StyleUtils = useStyleUtils(); | ||
|
||
return ( | ||
<SafeAreaConsumer> | ||
{({safeAreaPaddingBottomStyle}) => ( | ||
<Modal | ||
onClose={onCancel} | ||
isVisible={isVisible} | ||
type={shouldUseNarrowLayout ? CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED : CONST.MODAL.MODAL_TYPE.CONFIRM} | ||
innerContainerStyle={{...styles.pb5, ...styles.pt3, ...styles.boxShadowNone}} | ||
shouldEnableNewFocusManagement={shouldEnableNewFocusManagement} | ||
> | ||
<View style={safeAreaPaddingBottomStyle}> | ||
<View | ||
style={[ | ||
styles.mh3, | ||
styles.br3, | ||
styles.cardSectionIllustration, | ||
styles.alignItemsCenter, | ||
StyleUtils.getBackgroundColorStyle(LottieAnimations.Safe.backgroundColor), | ||
]} | ||
> | ||
<Lottie | ||
source={LottieAnimations.Safe} | ||
style={styles.h100} | ||
webStyle={styles.h100} | ||
autoPlay | ||
loop | ||
/> | ||
</View> | ||
<View style={[styles.mt5, styles.mh5]}> | ||
<View style={[styles.gap2, styles.mb10]}> | ||
<Text style={[styles.textHeadlineH1]}>{translate('twoFactorAuth.pleaseEnableTwoFactorAuth')}</Text> | ||
<Text style={styles.textSupporting}>{description}</Text> | ||
</View> | ||
<Button | ||
large | ||
success | ||
pressOnEnter | ||
onPress={onSubmit} | ||
text={translate('twoFactorAuth.enableTwoFactorAuth')} | ||
/> | ||
</View> | ||
</View> | ||
</Modal> | ||
)} | ||
</SafeAreaConsumer> | ||
); | ||
} | ||
|
||
RequireTwoFactorAuthenticationModal.displayName = 'RequireTwoFactorAuthenticationModal'; | ||
|
||
export default RequireTwoFactorAuthenticationModal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An edge case on ios hybrid required us to call
navigate
only after the modal is closed. This is addressed in #58245