Skip to content

Commit 0b97784

Browse files
atrakhConvex, Inc.
authored andcommitted
don't allow deleting emails that are associated with an identity (#41513)
Disallows deleting emails that are associated with an identity. GitOrigin-RevId: f779dfaaca0d423ed98b231b0256348edfa71c11
1 parent 4440000 commit 0b97784

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

npm-packages/dashboard/src/components/profile/ConnectedIdentities.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ export function ConnectedIdentities() {
3838
<Sheet className="flex flex-col gap-4">
3939
<h3>Identities</h3>
4040
<p className="max-w-prose text-sm">
41-
These are the identities associated with your account. Identities are
42-
used to login to Convex, and are distinct from the emails connected to
43-
your account for communication purposes.
41+
These are the identities associated with your account.
4442
</p>
4543
<p>
46-
When you login with an identity, it's email is automatically associated
47-
with your account.
44+
Identities are used to login to Convex, and are distinct from the emails
45+
connected to your account for communication purposes. However, you can
46+
only login with identities that are verified emails on your Convex
47+
account.
4848
</p>
4949
<LoadingTransition loadingProps={{ className: "h-[13rem]" }}>
5050
{identities && (
@@ -67,11 +67,11 @@ export function ConnectedIdentities() {
6767
dialogTitle="Unlink Identity"
6868
dialogBody={
6969
<div className="flex flex-col gap-1">
70+
<p>Are you sure you want to unlink this identity? </p>
7071
<p>
71-
Are you sure you want to unlink this identity? You will no
72-
longer be able to sign in with the providers associated with
73-
this identity unless the email associated with this identity is
74-
verified to your account.
72+
After you unlink this identity, you must also delete the
73+
associated email to restrict this email from logging in to
74+
Convex.
7575
</p>
7676
<p>
7777
Once you unlink this identity, you will be logged out of the

npm-packages/dashboard/src/components/profile/EmailList.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ jest.mock("api/profile", () => ({
77
useDeleteProfileEmail: jest.fn(),
88
useUpdatePrimaryProfileEmail: jest.fn(),
99
useResendProfileEmailVerification: jest.fn(),
10+
useIdentities: jest.fn(),
1011
}));
1112

1213
const mockEmails: MemberEmailResponse[] = [

npm-packages/dashboard/src/components/profile/EmailListItem.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jest.mock("api/profile", () => ({
1313
useDeleteProfileEmail: jest.fn(),
1414
useUpdatePrimaryProfileEmail: jest.fn(),
1515
useResendProfileEmailVerification: jest.fn(),
16+
useIdentities: jest.fn(),
1617
}));
1718

1819
const mockDeleteProfileEmail = useDeleteProfileEmail as jest.Mock;

npm-packages/dashboard/src/components/profile/EmailListItem.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ import { ConfirmationDialog } from "@ui/ConfirmationDialog";
33
import { Menu, MenuItem } from "@ui/Menu";
44
import {
55
useDeleteProfileEmail,
6+
useIdentities,
67
useResendProfileEmailVerification,
78
useUpdatePrimaryProfileEmail,
89
} from "api/profile";
910
import { useState } from "react";
1011
import { MemberEmailResponse } from "generatedApi";
1112

1213
export function EmailListItem({ email }: { email: MemberEmailResponse }) {
14+
const identities = useIdentities();
15+
const emailIsAnIdentity = identities?.some(
16+
(identity) => identity.email === email.email,
17+
);
1318
const deleteEmail = useDeleteProfileEmail();
1419
const updatePrimaryEmail = useUpdatePrimaryProfileEmail();
1520
const resentEmailVerification = useResendProfileEmailVerification();
@@ -60,12 +65,14 @@ export function EmailListItem({ email }: { email: MemberEmailResponse }) {
6065
) : null}
6166
<MenuItem
6267
action={() => setShowDeleteConfirmation(true)}
63-
disabled={email.isPrimary}
68+
disabled={email.isPrimary || emailIsAnIdentity}
6469
variant="danger"
6570
tip={
6671
email.isPrimary
6772
? "You cannot delete your primary email."
68-
: undefined
73+
: emailIsAnIdentity
74+
? "You cannot delete this email because it is associated with an identity on your account. Delete the identity first to remove this email from your account."
75+
: undefined
6976
}
7077
tipSide="right"
7178
>

0 commit comments

Comments
 (0)