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.

small fix

Steven Tey98f128f16ee5
diff --git a/lib/utils.ts b/lib/utils.ts
index a29fdcac96..e15d728e2e 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -347,17 +347,14 @@ export const isBlacklistedKey = async (key: string) => {
return new RegExp(blacklistedKeys.join("|"), "i").test(key);
};
-export const getBlackListedEmails = async () => {
+export const isBlacklistedEmail = async (email: string) => {
+ let blacklistedEmails;
try {
- const emails = await edgeConfig.get("emails");
- if (emails) {
- return new Set(emails);
- } else {
- return new Set();
- }
+ blacklistedEmails = await edgeConfig.get("emails");
} catch (e) {
- return new Set();
+ blacklistedEmails = [];
}
+ return new Set(blacklistedEmails).has(email);
};
export const isReservedKey = async (key: string) => {
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx
index 676b22d5bf..c7596e122e 100644
--- a/pages/api/auth/[...nextauth].tsx
+++ b/pages/api/auth/[...nextauth].tsx
@@ -5,7 +5,7 @@ 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 { getBlackListedEmails } from "@/lib/utils";
+import { isBlacklistedEmail } from "@/lib/utils";
const VERCEL_DEPLOYMENT = !!process.env.VERCEL_URL;
@@ -38,15 +38,13 @@ export const authOptions: NextAuthOptions = {
},
callbacks: {
signIn: async ({ user }) => {
- const BLACKLISTED_EMAILS = await getBlackListedEmails();
- if (BLACKLISTED_EMAILS.has(user.email)) {
+ if (await isBlacklistedEmail(user.email)) {
return false;
}
return true;
},
jwt: async ({ token, account }) => {
- const BLACKLISTED_EMAILS = await getBlackListedEmails();
- if (BLACKLISTED_EMAILS.has(token.email)) {
+ if (await isBlacklistedEmail(token.email)) {
return {};
}
if (account) {