1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

remove the ability to navigate back into the onboarding flow after completing onboarding (#16916)

* fix issue when navigating back into the onboarding flow after completing onboarding

* disable navigating back into the onboarding flow

* lint

* fix test

* lint
This commit is contained in:
Alex Donesky 2022-12-13 12:08:28 -06:00 committed by GitHub
parent a6da5fd4c3
commit 6a23dcc68a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 15 deletions

View File

@ -45,6 +45,7 @@ import {
VIEW_QUOTE_ROUTE, VIEW_QUOTE_ROUTE,
CONFIRMATION_V_NEXT_ROUTE, CONFIRMATION_V_NEXT_ROUTE,
ADD_COLLECTIBLE_ROUTE, ADD_COLLECTIBLE_ROUTE,
ONBOARDING_SECURE_YOUR_WALLET_ROUTE,
} from '../../helpers/constants/routes'; } from '../../helpers/constants/routes';
import ZENDESK_URLS from '../../helpers/constants/zendesk-url'; import ZENDESK_URLS from '../../helpers/constants/zendesk-url';
import Tooltip from '../../components/ui/tooltip'; import Tooltip from '../../components/ui/tooltip';
@ -414,12 +415,13 @@ export default class Home extends PureComponent {
descriptionText={t('backupApprovalNotice')} descriptionText={t('backupApprovalNotice')}
acceptText={t('backupNow')} acceptText={t('backupNow')}
onAccept={() => { onAccept={() => {
const backUpSRPRoute = process.env.ONBOARDING_V2
? `${ONBOARDING_SECURE_YOUR_WALLET_ROUTE}/?isFromReminder=true`
: INITIALIZE_BACKUP_SEED_PHRASE_ROUTE;
if (isPopup) { if (isPopup) {
global.platform.openExtensionInBrowser( global.platform.openExtensionInBrowser(backUpSRPRoute);
INITIALIZE_BACKUP_SEED_PHRASE_ROUTE,
);
} else { } else {
history.push(INITIALIZE_BACKUP_SEED_PHRASE_ROUTE); history.push(backUpSRPRoute);
} }
}} }}
infoText={t('backupApprovalInfo')} infoText={t('backupApprovalInfo')}

View File

@ -19,14 +19,12 @@ import {
ONBOARDING_PIN_EXTENSION_ROUTE, ONBOARDING_PIN_EXTENSION_ROUTE,
ONBOARDING_METAMETRICS, ONBOARDING_METAMETRICS,
} from '../../helpers/constants/routes'; } from '../../helpers/constants/routes';
import { import { getCompletedOnboarding } from '../../ducks/metamask/metamask';
getCompletedOnboarding,
getSeedPhraseBackedUp,
} from '../../ducks/metamask/metamask';
import { import {
createNewVaultAndGetSeedPhrase, createNewVaultAndGetSeedPhrase,
unlockAndGetSeedPhrase, unlockAndGetSeedPhrase,
createNewVaultAndRestore, createNewVaultAndRestore,
verifySeedPhrase,
} from '../../store/actions'; } from '../../store/actions';
import { getFirstTimeFlowTypeRoute } from '../../selectors'; import { getFirstTimeFlowTypeRoute } from '../../selectors';
import Button from '../../components/ui/button'; import Button from '../../components/ui/button';
@ -49,18 +47,29 @@ import MetaMetricsComponent from './metametrics/metametrics';
export default function OnboardingFlow() { export default function OnboardingFlow() {
const [secretRecoveryPhrase, setSecretRecoveryPhrase] = useState(''); const [secretRecoveryPhrase, setSecretRecoveryPhrase] = useState('');
const dispatch = useDispatch(); const dispatch = useDispatch();
const currentLocation = useLocation(); const { pathName, search } = useLocation();
const history = useHistory(); const history = useHistory();
const t = useI18nContext(); const t = useI18nContext();
const completedOnboarding = useSelector(getCompletedOnboarding); const completedOnboarding = useSelector(getCompletedOnboarding);
const seedPhraseBackedUp = useSelector(getSeedPhraseBackedUp);
const nextRoute = useSelector(getFirstTimeFlowTypeRoute); const nextRoute = useSelector(getFirstTimeFlowTypeRoute);
const isFromReminder = new URLSearchParams(search).get('isFromReminder');
useEffect(() => { useEffect(() => {
if (completedOnboarding && seedPhraseBackedUp) { if (completedOnboarding && !isFromReminder) {
history.push(DEFAULT_ROUTE); history.push(DEFAULT_ROUTE);
} }
}, [history, completedOnboarding, seedPhraseBackedUp]); }, [history, completedOnboarding, isFromReminder]);
useEffect(() => {
const verifyAndSetSeedPhrase = async () => {
if (completedOnboarding && !secretRecoveryPhrase) {
const verifiedSeedPhrase = await verifySeedPhrase();
if (verifiedSeedPhrase) {
setSecretRecoveryPhrase(verifiedSeedPhrase);
}
}
};
verifyAndSetSeedPhrase();
}, [completedOnboarding, secretRecoveryPhrase]);
const handleCreateNewAccount = async (password) => { const handleCreateNewAccount = async (password) => {
const newSecretRecoveryPhrase = await dispatch( const newSecretRecoveryPhrase = await dispatch(
@ -97,7 +106,6 @@ export default function OnboardingFlow() {
)} )}
/> />
<Route <Route
exact
path={ONBOARDING_SECURE_YOUR_WALLET_ROUTE} path={ONBOARDING_SECURE_YOUR_WALLET_ROUTE}
component={SecureYourWallet} component={SecureYourWallet}
/> />
@ -170,7 +178,7 @@ export default function OnboardingFlow() {
<Route exact path="*" component={OnboardingFlowSwitch} /> <Route exact path="*" component={OnboardingFlowSwitch} />
</Switch> </Switch>
</div> </div>
{currentLocation?.pathname === ONBOARDING_COMPLETION_ROUTE && ( {pathName === ONBOARDING_COMPLETION_ROUTE && (
<Button <Button
className="onboarding-flow__twitter-button" className="onboarding-flow__twitter-button"
type="link" type="link"

View File

@ -29,6 +29,7 @@ jest.mock('../../store/actions', () => ({
createNewVaultAndGetSeedPhrase: jest.fn().mockResolvedValue(null), createNewVaultAndGetSeedPhrase: jest.fn().mockResolvedValue(null),
unlockAndGetSeedPhrase: jest.fn().mockResolvedValue(null), unlockAndGetSeedPhrase: jest.fn().mockResolvedValue(null),
createNewVaultAndRestore: jest.fn(), createNewVaultAndRestore: jest.fn(),
verifySeedPhrase: jest.fn(),
})); }));
describe('Onboarding Flow', () => { describe('Onboarding Flow', () => {