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 token expiry

Kiran K83bfdee4adb0
diff --git a/apps/web/app/api/user/set-password/route.ts b/apps/web/app/api/user/set-password/route.ts
index f1b88948ed..c4f69be0d6 100644
--- a/apps/web/app/api/user/set-password/route.ts
+++ b/apps/web/app/api/user/set-password/route.ts
@@ -1,13 +1,12 @@
import { DubApiError } from "@/lib/api/errors";
import { withSession } from "@/lib/auth";
+import { PASSWORD_RESET_TOKEN_EXPIRY } from "@/lib/auth/password";
import { prisma } from "@/lib/prisma";
import { randomBytes } from "crypto";
import { sendEmail } from "emails";
import ResetPasswordLink from "emails/reset-password-link";
import { NextResponse } from "next/server";
-const PASSWORD_RESET_TOKEN_EXPIRY = 6 * 60 * 60 * 1000; // 6 hours
-
// POST /api/user/set-password - set account password (for users who signed up with a OAuth provider)
export const POST = withSession(async ({ session }) => {
const user = await prisma.user.findFirst({
@@ -33,7 +32,7 @@ export const POST = withSession(async ({ session }) => {
data: {
identifier: session.user.email,
token: randomBytes(32).toString("hex"),
- expires: new Date(Date.now() + PASSWORD_RESET_TOKEN_EXPIRY),
+ expires: new Date(Date.now() + PASSWORD_RESET_TOKEN_EXPIRY * 1000),
},
});
diff --git a/apps/web/lib/auth/password.ts b/apps/web/lib/auth/password.ts
index 122fe8ce41..4d108643af 100644
--- a/apps/web/lib/auth/password.ts
+++ b/apps/web/lib/auth/password.ts
@@ -13,3 +13,5 @@ export async function validatePassword({
}) {
return await compare(password, passwordHash);
}
+
+export const PASSWORD_RESET_TOKEN_EXPIRY = 1 * 60 * 60; // 1 hour