Skip to content

Commit

Permalink
fix: redirect back after successful unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Aug 12, 2022
1 parent 4cf384d commit 717ad60
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/app/features/container/container.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { Outlet, useSearchParams } from 'react-router-dom';
import { Outlet, useLocation, useSearchParams } from 'react-router-dom';

import { useRouteHeaderState } from '@app/store/ui/ui.hooks';
import { useInitialRouteSearchParams } from '@app/store/common/initial-route-search-params.hooks';
Expand Down
17 changes: 5 additions & 12 deletions src/app/pages/unlock.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { Stack } from '@stacks/ui';

Expand All @@ -7,25 +6,19 @@ import { useDrawers } from '@app/common/hooks/use-drawers';
import { Header } from '@app/components/header';
import { CenteredPageContainer } from '@app/components/centered-page-container';
import { SignOutConfirmDrawer } from '@app/pages/sign-out-confirm/sign-out-confirm';
import { useOnboardingState } from '@app/common/hooks/auth/use-onboarding-state';
import { CENTERED_FULL_PAGE_MAX_WIDTH } from '@app/components/global-styles/full-page-styles';
import { RouteUrls } from '@shared/route-urls';
import { RequestPassword } from '@app/components/request-password';

export function Unlock(): JSX.Element {
const { decodedAuthRequest } = useOnboardingState();
export function Unlock() {
const { showSignOut } = useDrawers();
const navigate = useNavigate();

useRouteHeader(<Header />);

const handleSuccess = useCallback(async () => {
if (decodedAuthRequest) {
navigate(RouteUrls.ChooseAccount);
} else {
navigate(RouteUrls.Home);
}
}, [decodedAuthRequest, navigate]);
// Users land on unlock page as they've been directed here from `<AccountGate/>`.
// On successful unlock, we can navigate back to the previous page, now
// with account details.
const handleSuccess = () => navigate(-1);

return (
<CenteredPageContainer>
Expand Down
2 changes: 1 addition & 1 deletion src/background/legacy-external-message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function handleLegacyExternalMethodFormat(
case ExternalMethods.authenticationRequest: {
const { urlParams, tabId } = makeSearchParamsWithDefaults(port, [['authRequest', payload]]);

const { id } = await triggerRequstWindowOpen(RouteUrls.Onboarding, urlParams);
const { id } = await triggerRequstWindowOpen(RouteUrls.ChooseAccount, urlParams);
listenForWindowClose({
id,
tabId,
Expand Down

0 comments on commit 717ad60

Please sign in to comment.