Skip to content

Commit 307806e

Browse files
author
Llorenç
committed
Add Migration flow into AuthFlow
1 parent 0963632 commit 307806e

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

src/frontend/src/lib/components/wizards/MigrationWizard.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import ProgressRing from "$lib/components/ui/ProgressRing.svelte";
88
import { handleError } from "$lib/components/utils/error";
99
10-
const { onSuccess }: { onSuccess: () => void } = $props();
10+
const { onSuccess }: { onSuccess: (identityNumber: bigint) => void } =
11+
$props();
1112
1213
let identityNumber: number | undefined = $state(undefined);
1314
const migrationFlow = new MigrationFlow();
@@ -23,7 +24,10 @@
2324
2425
const handleCreate = async (name: string) => {
2526
await migrationFlow.createPasskey(name);
26-
onSuccess();
27+
// Button is disabled if identityNumber is null or undefined so no need to manage that case.
28+
if (nonNullish(migrationFlow.identityNumber)) {
29+
onSuccess(migrationFlow.identityNumber);
30+
}
2731
};
2832
</script>
2933

src/frontend/src/lib/components/wizards/auth/AuthWizard.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import SystemOverlayBackdrop from "$lib/components/utils/SystemOverlayBackdrop.svelte";
1111
import { RegisterAccessMethodWizard } from "$lib/components/wizards/registerAccessMethod";
1212
import { canisterConfig } from "$lib/globals";
13+
import MigrationWizard from "../MigrationWizard.svelte";
1314
1415
interface Props {
1516
isAuthenticating?: boolean;
@@ -73,6 +74,10 @@
7374
onOtherDevice(identityNumber);
7475
}
7576
};
77+
78+
const handleMigrationSuccess = (identityNumber: bigint) => {
79+
onSignIn(identityNumber);
80+
};
7681
</script>
7782

7883
{#snippet dialogContent()}
@@ -83,6 +88,8 @@
8388
/>
8489
{:else if authFlow.view === "setupNewPasskey"}
8590
<CreatePasskey create={handleCreatePasskey} />
91+
{:else if authFlow.view === "migrate"}
92+
<MigrationWizard onSuccess={handleMigrationSuccess} />
8693
{/if}
8794
{/snippet}
8895

@@ -98,6 +105,7 @@
98105
continueWithGoogle={handleContinueWithGoogle}
99106
continueFromAnotherDevice={() =>
100107
(isContinueFromAnotherDeviceVisible = true)}
108+
migrate={authFlow.migrate}
101109
/>
102110
{/if}
103111
{#if authFlow.view !== "chooseMethod"}

src/frontend/src/lib/components/wizards/auth/views/PickAuthenticationMethod.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
setupOrUseExistingPasskey: () => void;
1616
continueWithGoogle: () => Promise<void>;
1717
continueFromAnotherDevice: () => void;
18+
migrate: () => void;
1819
}
1920
2021
const {
2122
setupOrUseExistingPasskey,
2223
continueWithGoogle,
2324
continueFromAnotherDevice,
25+
migrate,
2426
}: Props = $props();
2527
2628
let isAuthenticating = $state(false);
@@ -87,7 +89,7 @@
8789
class="text-text-primary text-md flex flex-row items-center justify-between"
8890
>
8991
<p>Still have an identity number?</p>
90-
<a href="/migrate" class="font-bold">Upgrade</a>
92+
<button onclick={migrate} class="font-bold">Upgrade</button>
9193
</div>
9294
{/if}
9395
</div>

src/frontend/src/lib/flows/authFlow.svelte.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import { createGoogleRequestConfig, requestJWT } from "$lib/utils/openID";
3232

3333
export class AuthFlow {
3434
#view = $state<
35-
"chooseMethod" | "setupOrUseExistingPasskey" | "setupNewPasskey"
35+
"chooseMethod" | "setupOrUseExistingPasskey" | "setupNewPasskey" | "migrate"
3636
>("chooseMethod");
3737
#captcha = $state<{
3838
image: string;
@@ -67,6 +67,10 @@ export class AuthFlow {
6767
this.#view = "chooseMethod";
6868
};
6969

70+
migrate = (): void => {
71+
this.#view = "migrate";
72+
};
73+
7074
setupOrUseExistingPasskey = (): void => {
7175
authenticationV2Funnel.trigger(
7276
AuthenticationV2Events.ContinueWithPasskeyScreen,

0 commit comments

Comments
 (0)