The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
remove existing otps while creating new one
Kiran K3d42c6a6f34e
diff --git a/apps/web/lib/actions/resend-otp.ts b/apps/web/lib/actions/resend-otp.tsindex 2a51b1fbe1..a6c5f6c042 100644--- a/apps/web/lib/actions/resend-otp.ts+++ b/apps/web/lib/actions/resend-otp.ts@@ -41,16 +41,23 @@ export const resendOtpAction = actionClientthrow new Error("An user with this email does not exist.");}- // Generate the OTPconst code = generateOTP();- await prisma.emailVerificationToken.create({- data: {- identifier: email,- token: code,- expires: new Date(Date.now() + EMAIL_OTP_EXPIRY_IN * 1000),- },- });+ await Promise.all([+ prisma.emailVerificationToken.deleteMany({+ where: {+ identifier: email,+ },+ }),++ prisma.emailVerificationToken.create({+ data: {+ identifier: email,+ token: code,+ expires: new Date(Date.now() + EMAIL_OTP_EXPIRY_IN * 1000),+ },+ }),+ ]);// Send email with generated OTPawait sendEmail({