Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Update merge-partner-accounts.ts

Kiran K51645c635718
diff --git a/apps/web/lib/actions/partners/merge-partner-accounts.ts b/apps/web/lib/actions/partners/merge-partner-accounts.ts
index fea480fd6d..7d04cafb77 100644
--- a/apps/web/lib/actions/partners/merge-partner-accounts.ts
+++ b/apps/web/lib/actions/partners/merge-partner-accounts.ts
@@ -41,12 +41,15 @@ const schema = z.discriminatedUnion("step", [
export const mergePartnerAccountsAction = authPartnerActionClient
.schema(schema)
.action(async ({ parsedInput, ctx }) => {
- const { user, partner } = ctx;
+ const { user } = ctx;
const { step } = parsedInput;
switch (step) {
case "send-tokens":
- return await sendTokens(parsedInput);
+ return await sendTokens({
+ ...parsedInput,
+ userId: user.id,
+ });
case "verify-tokens":
return await verifyTokens({
...parsedInput,
@@ -65,9 +68,11 @@ export const mergePartnerAccountsAction = authPartnerActionClient
const sendTokens = async ({
sourceEmail,
targetEmail,
+ userId,
}: {
sourceEmail: string;
targetEmail: string;
+ userId: string;
}) => {
if (sourceEmail === targetEmail) {
throw new Error("Source and target emails cannot be the same.");
@@ -105,13 +110,17 @@ const sendTokens = async ({
);
}
- await prisma.emailVerificationToken.deleteMany({
- where: {
- identifier: {
- in: [sourceEmail, targetEmail],
+ await Promise.all([
+ prisma.emailVerificationToken.deleteMany({
+ where: {
+ identifier: {
+ in: [sourceEmail, targetEmail],
+ },
},
- },
- });
+ }),
+
+ redis.del(`${CACHE_KEY_PREFIX}:${userId}`),
+ ]);
const sourceEmailCode = generateOTP();
const targetEmailCode = generateOTP();