Skip to content

Commit

Permalink
Merge pull request #45649 from Expensify/revert-44059-2fa
Browse files Browse the repository at this point in the history
Revert "[Wave Collect][Xero] Enforce 2FA for xero"
  • Loading branch information
mountiny authored Jul 18, 2024
2 parents 2a727fa + 40ad08f commit f36b308
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 244 deletions.
5 changes: 0 additions & 5 deletions .storybook/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ const webpackConfig = ({config}: {config: Configuration}) => {
}),
);

config.module.rules?.push({
test: /\.lottie$/,
type: 'asset/resource',
});

return config;
};

Expand Down
24 changes: 1 addition & 23 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import React, {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useStat
import type {NativeEventSubscription} from 'react-native';
import {AppState, Linking, NativeModules} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import Onyx, {useOnyx, withOnyx} from 'react-native-onyx';
import Onyx, {withOnyx} from 'react-native-onyx';
import ConfirmModal from './components/ConfirmModal';
import DeeplinkWrapper from './components/DeeplinkWrapper';
import EmojiPicker from './components/EmojiPicker/EmojiPicker';
import FocusModeNotification from './components/FocusModeNotification';
import GrowlNotification from './components/GrowlNotification';
import RequireTwoFactorAuthenticationModal from './components/RequireTwoFactorAuthenticationModal';
import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
import SplashScreenHider from './components/SplashScreenHider';
import UpdateAppModal from './components/UpdateAppModal';
Expand Down Expand Up @@ -38,7 +37,6 @@ import ONYXKEYS from './ONYXKEYS';
import PopoverReportActionContextMenu from './pages/home/report/ContextMenu/PopoverReportActionContextMenu';
import * as ReportActionContextMenu from './pages/home/report/ContextMenu/ReportActionContextMenu';
import type {Route} from './ROUTES';
import ROUTES from './ROUTES';
import type {ScreenShareRequest, Session} from './types/onyx';

Onyx.registerLogger(({level, message}) => {
Expand Down Expand Up @@ -103,16 +101,6 @@ function Expensify({
const [isSplashHidden, setIsSplashHidden] = useState(false);
const [hasAttemptedToOpenPublicRoom, setAttemptedToOpenPublicRoom] = useState(false);
const {translate} = useLocalize();
const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const [shouldShowRequire2FAModal, setShouldShowRequire2FAModal] = useState(false);

useEffect(() => {
if (!account?.needsTwoFactorAuthSetup || account.requiresTwoFactorAuth) {
return;
}
setShouldShowRequire2FAModal(true);
}, [account?.needsTwoFactorAuthSetup, account?.requiresTwoFactorAuth]);

const [initialUrl, setInitialUrl] = useState<string | null>(null);

useEffect(() => {
Expand Down Expand Up @@ -265,16 +253,6 @@ function Expensify({
/>
) : null}
{focusModeNotification ? <FocusModeNotification /> : null}
{shouldShowRequire2FAModal ? (
<RequireTwoFactorAuthenticationModal
onSubmit={() => {
setShouldShowRequire2FAModal(false);
Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.HOME));
}}
isVisible
description={translate('twoFactorAuth.twoFactorAuthIsRequiredForAdminsDescription')}
/>
) : null}
</>
)}

Expand Down
3 changes: 1 addition & 2 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ const ROUTES = {
},
SETTINGS_2FA: {
route: 'settings/security/two-factor-auth',
getRoute: (backTo?: string, forwardTo?: string) =>
getUrlWithBackToParam(forwardTo ? `settings/security/two-factor-auth?forwardTo=${encodeURIComponent(forwardTo)}` : 'settings/security/two-factor-auth', backTo),
getRoute: (backTo?: string) => getUrlWithBackToParam('settings/security/two-factor-auth', backTo),
},
SETTINGS_STATUS: 'settings/profile/status',

Expand Down
26 changes: 1 addition & 25 deletions src/components/ConnectToXeroButton/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import React, {useRef, useState} from 'react';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx, withOnyx} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {WebView} from 'react-native-webview';
import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal';
import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView';
import Button from '@components/Button';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import Modal from '@components/Modal';
import RequireTwoFactorAuthenticationModal from '@components/RequireTwoFactorAuthenticationModal';
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 getUAForWebView from '@libs/getUAForWebView';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Session} from '@src/types/onyx';
import type {ConnectToXeroButtonProps} from './types';

Expand All @@ -36,22 +33,13 @@ function ConnectToXeroButton({policyID, session, shouldDisconnectIntegrationBefo
const authToken = session?.authToken ?? null;
const {isOffline} = useNetwork();

const [account] = useOnyx(ONYXKEYS.ACCOUNT);
const is2FAEnabled = account?.requiresTwoFactorAuth ?? false;

const renderLoading = () => <FullScreenLoadingIndicator />;
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);
const [isRequire2FAModalOpen, setIsRequire2FAModalOpen] = useState(false);

return (
<>
<Button
onPress={() => {
if (!is2FAEnabled) {
setIsRequire2FAModalOpen(true);
return;
}

if (shouldDisconnectIntegrationBeforeConnecting && integrationToDisconnect) {
setIsDisconnectModalOpen(true);
return;
Expand All @@ -74,18 +62,6 @@ function ConnectToXeroButton({policyID, session, shouldDisconnectIntegrationBefo
onCancel={() => setIsDisconnectModalOpen(false)}
/>
)}
{isRequire2FAModalOpen && (
<RequireTwoFactorAuthenticationModal
onSubmit={() => {
setIsRequire2FAModalOpen(false);
Navigation.dismissModal();
Navigation.navigate(ROUTES.SETTINGS_2FA.getRoute(ROUTES.POLICY_ACCOUNTING.getRoute(policyID), getXeroSetupLink(policyID)));
}}
onCancel={() => setIsRequire2FAModalOpen(false)}
isVisible
description={translate('twoFactorAuth.twoFactorAuthIsRequiredDescription')}
/>
)}
<Modal
onClose={() => setWebViewOpen(false)}
fullscreen
Expand Down
26 changes: 0 additions & 26 deletions src/components/ConnectToXeroButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
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) {
Expand All @@ -22,21 +17,12 @@ 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;
Expand All @@ -59,18 +45,6 @@ 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)));
}}
onCancel={() => setIsRequire2FAModalOpen(false)}
isVisible
description={translate('twoFactorAuth.twoFactorAuthIsRequiredDescription')}
/>
)}
</>
);
}
Expand Down
91 changes: 0 additions & 91 deletions src/components/RequireTwoFactorAuthenticationModal.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,11 +1071,6 @@ export default {
enabled: 'Two-factor authentication is now enabled!',
congrats: 'Congrats, now you’ve got that extra security.',
copy: 'Copy',
disable: 'Disable',
enableTwoFactorAuth: 'Enable two-factor authentication',
pleaseEnableTwoFactorAuth: 'Please enable two-factor authentication.',
twoFactorAuthIsRequiredDescription: 'Two-factor authentication is required for connecting to Xero. Please enable two-factor authentication to continue.',
twoFactorAuthIsRequiredForAdminsDescription: 'Two-factor authentication is required for Xero workspace admins. Please enable two-factor authentication to continue.',
},
recoveryCodeForm: {
error: {
Expand Down
6 changes: 0 additions & 6 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1079,12 +1079,6 @@ export default {
enabled: '¡La autenticación de dos factores está ahora habilitada!',
congrats: 'Felicidades, ahora tienes esa seguridad adicional.',
copy: 'Copiar',
disable: 'Deshabilitar',
enableTwoFactorAuth: 'Activar la autenticación de dos factores',
pleaseEnableTwoFactorAuth: 'Activa la autenticación de dos factores.',
twoFactorAuthIsRequiredDescription: 'La autenticación de dos factores es necesaria para conectarse a Xero. Activa la autenticación de dos factores para continuar.',
twoFactorAuthIsRequiredForAdminsDescription:
'La autenticación de dos factores es necesaria para los administradores del área de trabajo de Xero. Activa la autenticación de dos factores para continuar.',
},
recoveryCodeForm: {
error: {
Expand Down
4 changes: 2 additions & 2 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const WRITE_COMMANDS = {
UNLINK_LOGIN: 'UnlinkLogin',
ENABLE_TWO_FACTOR_AUTH: 'EnableTwoFactorAuth',
DISABLE_TWO_FACTOR_AUTH: 'DisableTwoFactorAuth',
TWO_FACTOR_AUTH_VALIDATE: 'TwoFactorAuth_Validate',
ADD_COMMENT: 'AddComment',
ADD_ATTACHMENT: 'AddAttachment',
ADD_TEXT_AND_ATTACHMENT: 'AddTextAndAttachment',
Expand Down Expand Up @@ -380,6 +381,7 @@ type WriteCommandParameters = {
[WRITE_COMMANDS.UNLINK_LOGIN]: Parameters.UnlinkLoginParams;
[WRITE_COMMANDS.ENABLE_TWO_FACTOR_AUTH]: null;
[WRITE_COMMANDS.DISABLE_TWO_FACTOR_AUTH]: null;
[WRITE_COMMANDS.TWO_FACTOR_AUTH_VALIDATE]: Parameters.ValidateTwoFactorAuthParams;
[WRITE_COMMANDS.ADD_COMMENT]: Parameters.AddCommentOrAttachementParams;
[WRITE_COMMANDS.ADD_ATTACHMENT]: Parameters.AddCommentOrAttachementParams;
[WRITE_COMMANDS.ADD_TEXT_AND_ATTACHMENT]: Parameters.AddCommentOrAttachementParams;
Expand Down Expand Up @@ -752,7 +754,6 @@ const SIDE_EFFECT_REQUEST_COMMANDS = {
ADD_PAYMENT_CARD_GBR: 'AddPaymentCardGBP',
REVEAL_EXPENSIFY_CARD_DETAILS: 'RevealExpensifyCardDetails',
SWITCH_TO_OLD_DOT: 'SwitchToOldDot',
TWO_FACTOR_AUTH_VALIDATE: 'TwoFactorAuth_Validate',
} as const;

type SideEffectRequestCommand = ValueOf<typeof SIDE_EFFECT_REQUEST_COMMANDS>;
Expand All @@ -768,7 +769,6 @@ type SideEffectRequestCommandParameters = {
[SIDE_EFFECT_REQUEST_COMMANDS.GENERATE_SPOTNANA_TOKEN]: Parameters.GenerateSpotnanaTokenParams;
[SIDE_EFFECT_REQUEST_COMMANDS.ADD_PAYMENT_CARD_GBR]: Parameters.AddPaymentCardParams;
[SIDE_EFFECT_REQUEST_COMMANDS.ACCEPT_SPOTNANA_TERMS]: null;
[SIDE_EFFECT_REQUEST_COMMANDS.TWO_FACTOR_AUTH_VALIDATE]: Parameters.ValidateTwoFactorAuthParams;
};

type ApiRequestCommandParameters = WriteCommandParameters & ReadCommandParameters & SideEffectRequestCommandParameters;
Expand Down
Loading

0 comments on commit f36b308

Please sign in to comment.