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.

fix race condition in sendOtpAction

Steven Teyaa1ae3309dc1
diff --git a/apps/web/lib/actions/send-otp.ts b/apps/web/lib/actions/send-otp.ts
index c35e7ade0f..0ee117caf3 100644
--- a/apps/web/lib/actions/send-otp.ts
+++ b/apps/web/lib/actions/send-otp.ts
@@ -47,13 +47,13 @@ export const sendOtpAction = actionClient
const code = generateOTP();
- await Promise.all([
- prisma.emailVerificationToken.deleteMany({
- where: {
- identifier: email,
- },
- }),
+ await prisma.emailVerificationToken.deleteMany({
+ where: {
+ identifier: email,
+ },
+ });
+ await Promise.all([
prisma.emailVerificationToken.create({
data: {
identifier: email,
@@ -61,16 +61,15 @@ export const sendOtpAction = actionClient
expires: new Date(Date.now() + EMAIL_OTP_EXPIRY_IN * 1000),
},
}),
- ]);
-
- await sendEmail({
- subject: `${process.env.NEXT_PUBLIC_APP_NAME}: OTP to verify your account`,
- email,
- react: VerifyEmail({
+ sendEmail({
+ subject: `${process.env.NEXT_PUBLIC_APP_NAME}: OTP to verify your account`,
email,
- code,
+ react: VerifyEmail({
+ email,
+ code,
+ }),
}),
- });
+ ]);
return { ok: true };
});