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.

limit blacklist to domains only, not emails

Steven Tey1f324e5f0754
diff --git a/lib/constants/blacklisted-domains.ts b/lib/constants/blacklist.ts
similarity index 98%
rename from lib/constants/blacklisted-domains.ts
rename to lib/constants/blacklist.ts
index e6b7a55d97..2f1a7cee65 100644
--- a/lib/constants/blacklisted-domains.ts
+++ b/lib/constants/blacklist.ts
@@ -1,4 +1,4 @@
-const BLACKLISTED_DOMAINS = new Set([
+const BLACKLIST = new Set([
"lopescarvalho.adv.br",
"piracynchill.in",
"tgnewstv.it",
@@ -156,4 +156,4 @@ const BLACKLISTED_DOMAINS = new Set([
"682rb.app.link",
]);
-export default BLACKLISTED_DOMAINS;
+export default BLACKLIST;
diff --git a/lib/constants/blacklisted-emails.ts b/lib/constants/blacklisted-emails.ts
deleted file mode 100644
index 7ab9bf8971..0000000000
--- a/lib/constants/blacklisted-emails.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-const BLACKLISTED_EMAILS = new Set(["hi2.in", "gmx.com"]);
-
-export default BLACKLISTED_EMAILS;
diff --git a/lib/constants/index.ts b/lib/constants/index.ts
index 5d41610ac6..7e495520bc 100644
--- a/lib/constants/index.ts
+++ b/lib/constants/index.ts
@@ -42,5 +42,4 @@ export const SPECIAL_APEX_DOMAINS = {
"youtu.be": "youtube.com",
};
-export { default as BLACKLISTED_DOMAINS } from "./blacklisted-domains";
-export { default as BLACKLISTED_EMAILS } from "./blacklisted-emails";
+export { default as BLACKLIST } from "./blacklist";
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx
index cc18b10300..f875116e94 100644
--- a/pages/api/auth/[...nextauth].tsx
+++ b/pages/api/auth/[...nextauth].tsx
@@ -5,7 +5,6 @@ import WelcomeEmail from "emails/WelcomeEmail";
import NextAuth, { type NextAuthOptions } from "next-auth";
import EmailProvider from "next-auth/providers/email";
import prisma from "@/lib/prisma";
-import { BLACKLISTED_EMAILS } from "@/lib/constants";
const VERCEL_DEPLOYMENT = !!process.env.VERCEL_URL;
@@ -37,12 +36,6 @@ export const authOptions: NextAuthOptions = {
},
},
callbacks: {
- signIn: async ({ user }) => {
- if (BLACKLISTED_EMAILS.has(user.email.split("@")[1])) {
- return false;
- }
- return true;
- },
session: async ({ session, token }) => {
session.user = {
// @ts-ignore
diff --git a/pages/api/edge/links/index.ts b/pages/api/edge/links/index.ts
index 1e681d6eac..70a7330faf 100644
--- a/pages/api/edge/links/index.ts
+++ b/pages/api/edge/links/index.ts
@@ -1,6 +1,6 @@
import type { NextRequest } from "next/server";
import { setRandomKey } from "@/lib/upstash";
-import { BLACKLISTED_DOMAINS } from "@/lib/constants";
+import { SECOND_LEVEL_DOMAINS } from "@/lib/constants";
import { getDomainWithoutWWW } from "@/lib/utils";
export const config = {
@@ -13,7 +13,7 @@ export default async function handler(req: NextRequest) {
if (!url) {
return new Response(`Missing url`, { status: 400 });
}
- if (BLACKLISTED_DOMAINS.has(getDomainWithoutWWW(url))) {
+ if (SECOND_LEVEL_DOMAINS.has(getDomainWithoutWWW(url))) {
return new Response(`Invalid url`, { status: 400 });
}
const { response, key } = await setRandomKey(url);
diff --git a/pages/api/links/index.ts b/pages/api/links/index.ts
index a2c98bc79f..ca738e6691 100644
--- a/pages/api/links/index.ts
+++ b/pages/api/links/index.ts
@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from "next";
import { addLink, getLinksForProject } from "@/lib/api/links";
import { Session, withUserAuth } from "@/lib/auth";
-import { BLACKLISTED_DOMAINS } from "@/lib/constants";
+import { SECOND_LEVEL_DOMAINS } from "@/lib/constants";
import { getDomainWithoutWWW } from "@/lib/utils";
// This is a special route for retrieving and creating custom dub.sh links.
@@ -28,7 +28,7 @@ export default withUserAuth(
if (!key || !url) {
return res.status(400).json({ error: "Missing key or url" });
}
- if (BLACKLISTED_DOMAINS.has(getDomainWithoutWWW(url))) {
+ if (SECOND_LEVEL_DOMAINS.has(getDomainWithoutWWW(url))) {
return res.status(400).json({ error: "Invalid url" });
}
const response = await addLink({