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.

remove cookie for password protected links

Steven Tey835156614423
diff --git a/lib/middleware/link.ts b/lib/middleware/link.ts
index c3f1e8b2f7..cc4d10df38 100644
--- a/lib/middleware/link.ts
+++ b/lib/middleware/link.ts
@@ -26,8 +26,8 @@ export default async function LinkMiddleware(
ev.waitUntil(recordClick(domain, req, key)); // track the click only if there is no `dub-no-track` header
}
- if (password && !req.cookies.get("dub_authenticated")) {
- // rewrite to auth page (/_auth/[domain]/[key]) if the link is password protected and the user has not authenticated before
+ if (password) {
+ // rewrite to auth page (/_auth/[domain]/[key]) if the link is password protected
return NextResponse.rewrite(new URL(`/_auth/${domain}/${key}`, req.url));
}
diff --git a/pages/api/auth/decrypt-password.ts b/pages/api/auth/decrypt-password.ts
index 614752d439..ca8bbb34fc 100644
--- a/pages/api/auth/decrypt-password.ts
+++ b/pages/api/auth/decrypt-password.ts
@@ -1,5 +1,4 @@
import { NextApiRequest, NextApiResponse } from "next";
-import { serialize } from "cookie";
import prisma from "@/lib/prisma";
export default async function handler(
@@ -14,17 +13,6 @@ export default async function handler(
});
const validPassword = password === realPassword;
if (validPassword) {
- // Set cookie to authenticate user for 1 week
- res.setHeader(
- "Set-Cookie",
- serialize("dub_authenticated", "1", {
- path: `/${key}`,
- maxAge: 60 * 60 * 24 * 7, // 1 week
- httpOnly: true,
- domain: process.env.NODE_ENV === "production" ? domain : null,
- secure: process.env.NODE_ENV === "production",
- }),
- );
return res.status(200).json({ url });
} else {
return res.status(401).json({ error: "Invalid password" });