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

Kiran K816c8fe2ee5e
diff --git a/apps/web/lib/referrals/auth.ts b/apps/web/lib/referrals/auth.ts
index 8ac0d0c0ba..63c8924bae 100644
--- a/apps/web/lib/referrals/auth.ts
+++ b/apps/web/lib/referrals/auth.ts
@@ -61,12 +61,18 @@ export const withAuth = (handler: WithAuthHandler) => {
});
}
- const referralToken =
- await prisma.referralPublicToken.findUniqueOrThrow({
- where: {
- publicToken,
- },
+ const referralToken = await prisma.referralPublicToken.findUnique({
+ where: {
+ publicToken,
+ },
+ });
+
+ if (!referralToken) {
+ throw new DubApiError({
+ code: "unauthorized",
+ message: "Invalid public token.",
});
+ }
if (referralToken.expires < new Date()) {
throw new DubApiError({
@@ -99,13 +105,6 @@ export const withAuth = (handler: WithAuthHandler) => {
"1 m",
).limit(publicToken);
- if (!success) {
- throw new DubApiError({
- code: "rate_limit_exceeded",
- message: "Too many requests.",
- });
- }
-
headers = {
"Retry-After": reset.toString(),
"X-RateLimit-Limit": limit.toString(),