diff --git a/src/frontend/src/lib/components/views/AccessMethods.svelte b/src/frontend/src/lib/components/views/AccessMethods.svelte index d1eaaf4b60..3503f79aea 100644 --- a/src/frontend/src/lib/components/views/AccessMethods.svelte +++ b/src/frontend/src/lib/components/views/AccessMethods.svelte @@ -5,14 +5,14 @@ import identityInfo from "$lib/stores/identity-info.state.svelte"; import AccessMethod from "$lib/components/ui/AccessMethod.svelte"; import PasskeyIcon from "$lib/components/icons/PasskeyIcon.svelte"; - import RemoveOpenIdCredential from "$lib/components/views/RemoveOpenIdCredential.svelte"; + import UnlinkOpenIdCredential from "$lib/components/views/UnlinkOpenIdCredential.svelte"; import { invalidateAll } from "$app/navigation"; import type { AuthnMethodData, OpenIdCredential, } from "$lib/generated/internet_identity_types"; - import RemovePasskeyDialog from "$lib/components/views/RemovePasskeyDialog.svelte"; - import RenamePasskeyDialog from "$lib/components/views/RenamePasskeyDialog.svelte"; + import RemovePasskey from "$lib/components/views/RemovePasskey.svelte"; + import RenamePasskey from "$lib/components/views/RenamePasskey.svelte"; import { nonNullish } from "@dfinity/utils"; import { handleError } from "$lib/components/utils/error"; import { @@ -27,6 +27,7 @@ import { openIdLogo, openIdName } from "$lib/utils/openID"; import Tooltip from "../ui/Tooltip.svelte"; import { accessMethods } from "$lib/derived/accessMethods.derived.svelte"; + import Dialog from "$lib/components/ui/Dialog.svelte"; let isAddAccessMethodWizardOpen = $state(false); let removableAuthnMethod = $state(null); @@ -239,31 +240,37 @@ {#if removableOpenIdCredential} - (removableOpenIdCredential = null)} - openIDName={openIdName( - removableOpenIdCredential.iss, - removableOpenIdCredential.metadata, - ) ?? "Google"} - isCurrentAccessMethod={isRemovableOpenIdCredentialCurrentAccessMethod} - /> + (removableOpenIdCredential = null)}> + (removableOpenIdCredential = null)} + providerName={openIdName( + removableOpenIdCredential.iss, + removableOpenIdCredential.metadata, + ) ?? "Google"} + isCurrentAccessMethod={isRemovableOpenIdCredentialCurrentAccessMethod} + /> + {/if} {#if removableAuthnMethod} - (removableAuthnMethod = null)} - isCurrentAccessMethod={isRemovableAuthnMethodCurrentAccessMethod} - /> + (removableAuthnMethod = null)}> + (removableAuthnMethod = null)} + isCurrentAccessMethod={isRemovableAuthnMethodCurrentAccessMethod} + /> + {/if} {#if renamableAuthnMethod} - (renamableAuthnMethod = null)} - /> + (renamableAuthnMethod = null)}> + (renamableAuthnMethod = null)} + /> + {/if} {#if isAddAccessMethodWizardOpen} diff --git a/src/frontend/src/lib/components/views/EditAccount.svelte b/src/frontend/src/lib/components/views/EditAccount.svelte index d80a86df06..c1ec5438c6 100644 --- a/src/frontend/src/lib/components/views/EditAccount.svelte +++ b/src/frontend/src/lib/components/views/EditAccount.svelte @@ -103,7 +103,7 @@ variant="primary" size="lg" type="submit" - disabled={name.length === 0 || + disabled={name.trim().length === 0 || name.length > 32 || !hasChanges || nameExists || diff --git a/src/frontend/src/lib/components/views/RemoveOpenIdCredential.svelte b/src/frontend/src/lib/components/views/RemoveOpenIdCredential.svelte deleted file mode 100644 index 5ef231fa22..0000000000 --- a/src/frontend/src/lib/components/views/RemoveOpenIdCredential.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - -

Are you sure?

-

- You're about to unlink your {openIDName} account. If you proceed, you will no - longer be able to sign-in to your identity or dapps using your {openIDName} account. - {#if isCurrentAccessMethod} -

As you are currently signed in with this Account, you will be - signed out. - {/if} -

- -
- - -
-
diff --git a/src/frontend/src/lib/components/views/RemovePasskey.svelte b/src/frontend/src/lib/components/views/RemovePasskey.svelte new file mode 100644 index 0000000000..a8323d3951 --- /dev/null +++ b/src/frontend/src/lib/components/views/RemovePasskey.svelte @@ -0,0 +1,80 @@ + + +
+
+ + + +

+ {$t`Are you sure?`} +

+
+

+ + Removing this passkey means you won't be able to use it to sign in + anymore. You can always add a new one later. + +

+

+ It won't be removed from your device or password manager. +

+ {#if isCurrentAccessMethod} +

+ + As you are currently signed in with this passkey, you will be signed + out. + +

+ {/if} +
+
+
+ + +
+
diff --git a/src/frontend/src/lib/components/views/RemovePasskeyDialog.svelte b/src/frontend/src/lib/components/views/RemovePasskeyDialog.svelte deleted file mode 100644 index 4712e6d890..0000000000 --- a/src/frontend/src/lib/components/views/RemovePasskeyDialog.svelte +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - -

Are you sure?

-

- Removing this passkey means you won't be able to use it to sign in anymore. - You can always add a new one later. -

- It won't be removed from your device or password manager. - {#if isCurrentAccessMethod} -

- As you are currently signed in with this passkey, you will be signed out. - {/if} -

- - -
diff --git a/src/frontend/src/lib/components/views/RenamePasskey.svelte b/src/frontend/src/lib/components/views/RenamePasskey.svelte new file mode 100644 index 0000000000..fdb3742fa4 --- /dev/null +++ b/src/frontend/src/lib/components/views/RenamePasskey.svelte @@ -0,0 +1,90 @@ + + +
+
+ + + +

+ {$t`Rename passkey`} +

+

+ {$t`Give your passkey a memorable name to help you identify it.`} +

+ 32 + ? $t`Maximum length is 32 characters.` + : undefined} + disabled={isSubmitting} + aria-label={$t`Passkey name`} + /> +
+
+ + +
+
diff --git a/src/frontend/src/lib/components/views/RenamePasskeyDialog.svelte b/src/frontend/src/lib/components/views/RenamePasskeyDialog.svelte deleted file mode 100644 index 6aa2a423a8..0000000000 --- a/src/frontend/src/lib/components/views/RenamePasskeyDialog.svelte +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - -

Rename passkey

-

- Give your passkey a memorable name to help you identify it. -

- -
- -
- - -
-
-
diff --git a/src/frontend/src/lib/components/views/UnlinkOpenIdCredential.svelte b/src/frontend/src/lib/components/views/UnlinkOpenIdCredential.svelte new file mode 100644 index 0000000000..9b9bf84262 --- /dev/null +++ b/src/frontend/src/lib/components/views/UnlinkOpenIdCredential.svelte @@ -0,0 +1,89 @@ + + +
+
+ + + +

+ {$t`Are you sure?`} +

+
+

+ + You're about to unlink your {name} account. + +

+

+ + If you proceed, you will no longer be able to sign-in to your identity + or dapps using your {name} + account. + +

+ {#if isCurrentAccessMethod} +

+ + As you are currently signed in with this Account, you will be signed + out. + +

+ {/if} +
+
+
+ + +
+
diff --git a/src/frontend/tests/e2e-playwright/dashboard/renamePasskeys.spec.ts b/src/frontend/tests/e2e-playwright/dashboard/renamePasskeys.spec.ts index 7f15b5f65f..8a18e02f92 100644 --- a/src/frontend/tests/e2e-playwright/dashboard/renamePasskeys.spec.ts +++ b/src/frontend/tests/e2e-playwright/dashboard/renamePasskeys.spec.ts @@ -155,8 +155,9 @@ test("User cannot rename passkey to an empty name nor is it renamed on cancel", const input = page.getByRole("textbox"); const saveButton = page.getByRole("button", { name: "Save" }); - // Initially, the Save button should be enabled with the pre-filled name - await expect(saveButton).toBeEnabled(); + // Initially, the Save button should be disabled with the pre-filled name + // since it's unchanged. + await expect(saveButton).toBeDisabled(); // Clear the input field (make it empty) await input.clear();