A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix: invalidate existing password reset tokens before issuing a new one (#2722)
Mohamed Bassem35dcf80f121b
diff --git a/packages/trpc/models/users.ts b/packages/trpc/models/users.tsindex 3340956a..b77c3a19 100644--- a/packages/trpc/models/users.ts+++ b/packages/trpc/models/users.ts@@ -291,10 +291,17 @@ export class User {const token = randomBytes(32).toString("hex");const expires = new Date(Date.now() + 60 * 60 * 1000); // 1 hour- await ctx.db.insert(passwordResetTokens).values({- userId: user.id,- token,- expires,+ await ctx.db.transaction(async (tx) => {+ // Invalidate any existing reset tokens for this user+ await tx+ .delete(passwordResetTokens)+ .where(eq(passwordResetTokens.userId, user.id));++ await tx.insert(passwordResetTokens).values({+ userId: user.id,+ token,+ expires,+ });});await sendPasswordResetEmail(email, user.name, token);