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 request-password-reset.ts

Kiran K33c19db38eb4
diff --git a/apps/web/lib/actions/request-password-reset.ts b/apps/web/lib/actions/request-password-reset.ts
index c24ca74abb..118fb2ca49 100644
--- a/apps/web/lib/actions/request-password-reset.ts
+++ b/apps/web/lib/actions/request-password-reset.ts
@@ -41,13 +41,16 @@ export const requestPasswordResetAction = actionClient
const token = randomBytes(32).toString("hex");
- await Promise.all([
+ // Run this sequentially to avoid race conditions
+ await prisma.$transaction([
+ // Remove old password reset tokens
prisma.passwordResetToken.deleteMany({
where: {
identifier: email,
},
}),
+ // Create a new password reset token
prisma.passwordResetToken.create({
data: {
identifier: email,