From ae3d8a7c23132e474b5f43cfbcb5d14e5f641edc Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Wed, 6 Oct 2021 16:28:20 -0700 Subject: [PATCH] Rip out unused routes --- src/ROUTES.js | 6 - src/SCREENS.js | 4 - .../Navigation/AppNavigator/AuthScreens.js | 11 -- .../Navigation/AppNavigator/PublicScreens.js | 28 --- src/libs/Navigation/linkingConfig.js | 5 - src/pages/LoginWithValidateCode2FAPage.js | 186 ------------------ src/pages/LoginWithValidateCodePage.js | 105 ---------- src/pages/SetPasswordPage.js | 18 +- src/pages/ValidateLoginPage.js | 35 ---- src/pages/validateLinkPropTypes.js | 18 -- 10 files changed, 16 insertions(+), 400 deletions(-) delete mode 100644 src/pages/LoginWithValidateCode2FAPage.js delete mode 100644 src/pages/LoginWithValidateCodePage.js delete mode 100644 src/pages/ValidateLoginPage.js delete mode 100644 src/pages/validateLinkPropTypes.js diff --git a/src/ROUTES.js b/src/ROUTES.js index 860b1f597ef3..ead92ef21161 100644 --- a/src/ROUTES.js +++ b/src/ROUTES.js @@ -66,16 +66,10 @@ export default { ) => `r/${reportID}/participants/details?login=${encodeURIComponent(login)}`, REPORT_WITH_ID_DETAILS: 'r/:reportID/details', getReportDetailsRoute: reportID => `r/${reportID}/details`, - VALIDATE_LOGIN: 'v', - VALIDATE_LOGIN_WITH_VALIDATE_CODE: 'v/:accountID/:validateCode', LOGIN_WITH_SHORT_LIVED_TOKEN: 'transition', // This is a special validation URL that will take the user to /workspace/new after validation. This is used // when linking users from e.com in order to share a session in this app. - LOGIN_WITH_VALIDATE_CODE_NEW_WORKSPACE: 'v/:accountID/:validateCode/new-workspace', - LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE: 'v/:accountID/:validateCode/2fa/new-workspace', - LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD: 'v/:accountID/:validateCode/workspace/:policyID/card', - LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD: 'v/:accountID/:validateCode/2fa/workspace/:policyID/card', ENABLE_PAYMENTS: 'enable-payments', WORKSPACE: 'workspace', WORKSPACE_CARD: ':policyID/card', diff --git a/src/SCREENS.js b/src/SCREENS.js index 3a9754a1ee76..7b92986721a4 100644 --- a/src/SCREENS.js +++ b/src/SCREENS.js @@ -7,8 +7,4 @@ export default { LOADING: 'Loading', REPORT: 'Report', LOG_IN_WITH_SHORT_LIVED_TOKEN: 'LogInWithShortLivedToken', - LOGIN_WITH_VALIDATE_CODE_NEW_WORKSPACE: 'LoginWithValidateCodeNewWorkspace', - LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE: 'LoginWithValidateCode2FANewWorkspace', - LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD: 'LoginWithValidateCodeWorkspaceCard', - LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD: 'LoginWithValidateCode2FAWorkspaceCard', }; diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 8829f5b17cb4..a3c879c70889 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -37,9 +37,6 @@ import {fetchFreePlanVerifiedBankAccount} from '../../actions/BankAccounts'; // Main drawer navigator import MainDrawerNavigator from './MainDrawerNavigator'; -// Validate login page -import ValidateLoginPage from '../../../pages/ValidateLoginPage'; - // Modal Stack Navigators import { IOUBillStackNavigator, @@ -303,14 +300,6 @@ class AuthScreens extends React.Component { }} component={MainDrawerNavigator} /> - ( options={defaultScreenOptions} component={LogInWithShortLivedTokenPage} /> - - - - - ); diff --git a/src/libs/Navigation/linkingConfig.js b/src/libs/Navigation/linkingConfig.js index 7f246559de0c..03e2973cfea1 100644 --- a/src/libs/Navigation/linkingConfig.js +++ b/src/libs/Navigation/linkingConfig.js @@ -27,11 +27,6 @@ export default { // Main Routes SetPassword: ROUTES.SET_PASSWORD_WITH_VALIDATE_CODE, - ValidateLogin: ROUTES.VALIDATE_LOGIN_WITH_VALIDATE_CODE, - [SCREENS.LOGIN_WITH_VALIDATE_CODE_NEW_WORKSPACE]: ROUTES.LOGIN_WITH_VALIDATE_CODE_NEW_WORKSPACE, - [SCREENS.LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE]: ROUTES.LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE, - [SCREENS.LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD]: ROUTES.LOGIN_WITH_VALIDATE_CODE_WORKSPACE_CARD, - [SCREENS.LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD]: ROUTES.LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD, [SCREENS.LOG_IN_WITH_SHORT_LIVED_TOKEN]: ROUTES.LOGIN_WITH_SHORT_LIVED_TOKEN, // Modal Screens diff --git a/src/pages/LoginWithValidateCode2FAPage.js b/src/pages/LoginWithValidateCode2FAPage.js deleted file mode 100644 index 5484242544d7..000000000000 --- a/src/pages/LoginWithValidateCode2FAPage.js +++ /dev/null @@ -1,186 +0,0 @@ -import React, {Component} from 'react'; -import {TextInput, View} from 'react-native'; -import lodashGet from 'lodash/get'; -import PropTypes from 'prop-types'; -import {withOnyx} from 'react-native-onyx'; -import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; -import validateLinkPropTypes from './validateLinkPropTypes'; -import {continueSessionFromECom} from '../libs/actions/Session'; -import styles from '../styles/styles'; -import ExpensifyCashLogo from '../components/ExpensifyCashLogo'; -import variables from '../styles/variables'; -import themeColors from '../styles/themes/default'; -import CONST from '../CONST'; -import Button from '../components/Button'; -import Text from '../components/Text'; -import compose from '../libs/compose'; -import ONYXKEYS from '../ONYXKEYS'; -import Navigation from '../libs/Navigation/Navigation'; -import ROUTES from '../ROUTES'; -import SCREENS from '../SCREENS'; -import * as Policy from '../libs/actions/Policy'; -import Permissions from '../libs/Permissions'; -import FullScreenLoadingIndicator from '../components/FullscreenLoadingIndicator'; - -const propTypes = { - /* Onyx Props */ - - /** The data about the current session */ - session: PropTypes.shape({ - /** The authToken for the current session */ - authToken: PropTypes.string, - }), - - /** The route name, accountID, and validateCode are passed via the URL */ - route: validateLinkPropTypes, - - /** List of betas */ - betas: PropTypes.arrayOf(PropTypes.string), - - ...withLocalizePropTypes, -}; - -const defaultProps = { - route: { - params: {}, - }, - session: {}, - betas: [], -}; -class LoginWithValidateCode2FAPage extends Component { - constructor(props) { - super(props); - - this.validateAndSubmitForm = this.validateAndSubmitForm.bind(this); - - this.state = { - twoFactorAuthCode: '', - formError: false, - loading: false, - }; - } - - componentDidMount() { - // If the user has an active session already, they need to be redirected straight to the relevant page - if (this.props.session.authToken) { - // In order to navigate to a modal, we first have to dismiss the current modal. But there is no current - // modal you say? I know, it confuses me too. Without dismissing the current modal, if the user cancels out - // of the new workspace modal, then they will be routed back to - // /v///workspace/123/card and we don't want that. We want them to go back to `/` - // and by calling dismissModal(), the /v/... route is removed from history so the user will get taken to `/` - // if they cancel out of the new workspace modal. - Navigation.dismissModal(); - if (Permissions.canUseFreePlan(this.props.betas)) { - this.rerouteToRelevantPage(); - } - } - } - - componentDidUpdate() { - // Betas can be loaded a little after a user is authenticated, so check again if the betas have been updated - if (this.props.session.authToken && Permissions.canUseFreePlan(this.props.betas)) { - this.rerouteToRelevantPage(); - } - } - - rerouteToRelevantPage() { - // Since all 2FA validate code login routes lead to this component, redirect to the appropriate page based on - // the original route. - switch (this.props.route.name) { - case SCREENS.LOGIN_WITH_VALIDATE_CODE_2FA_WORKSPACE_CARD: - Navigation.navigate(ROUTES.getWorkspaceCardRoute(this.props.route.params.policyID)); - break; - - case SCREENS.LOGIN_WITH_VALIDATE_CODE_2FA_NEW_WORKSPACE: - // Creating a policy will reroute the user to the settings page afterwards - Policy.create(); - break; - - default: - Navigation.navigate(ROUTES.HOME); - break; - } - } - - validateAndSubmitForm() { - if (!this.state.twoFactorAuthCode.trim()) { - this.setState({formError: this.props.translate('passwordForm.pleaseFillOutAllFields')}); - return; - } - - this.setState({ - formError: null, - loading: true, - }); - - const accountID = lodashGet(this.props.route.params, 'accountID', ''); - const validateCode = lodashGet(this.props.route.params, 'validateCode', ''); - continueSessionFromECom(accountID, validateCode, this.state.twoFactorAuthCode); - } - - render() { - // Show a loader so that the user isn't immediately kicked to the home page before rerouteToRelevantPage runs - if (this.props.session.authToken) { - return ; - } - - return ( - - - - - - - {this.props.translate('signInPage.expensifyDotCash')} - - - - - - - {this.props.translate('passwordForm.enterYourTwoFactorAuthenticationCodeToContinue')} - - this.setState({twoFactorAuthCode: text})} - onSubmitEditing={this.validateAndSubmitForm} - keyboardType={CONST.KEYBOARD_TYPE.NUMERIC} - /> - - -