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.

change buffer range to 5 mins

Steven Tey922e5a5d7483
diff --git a/.gitignore b/.gitignore
index 6083da7e2b..530473f69d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,7 +37,6 @@ yarn-error.log*
next-env.d.ts
/pages/api/scripts*
-.mailing
.react-email
.contentlayer
.vscode
diff --git a/lib/middleware/app.ts b/lib/middleware/app.ts
index 812c6bd576..281cbf4992 100644
--- a/lib/middleware/app.ts
+++ b/lib/middleware/app.ts
@@ -23,11 +23,11 @@ export default async function AppMiddleware(req: NextRequest) {
// if there's a session
} else if (session?.email) {
- // if the user was created in the last 10 seconds, redirect to "/welcome"
+ // if the user was created in the last 5 minutes and the path isn't /welcome, redirect to /welcome
// (this is a workaround because the `isNewUser` flag is triggered when a user does `dangerousEmailAccountLinking`)
if (
session?.user?.createdAt &&
- new Date(session?.user?.createdAt).getTime() > Date.now() - 10000 &&
+ new Date(session?.user?.createdAt).getTime() > Date.now() - 300000 &&
path !== "/welcome"
) {
return NextResponse.redirect(new URL("/welcome", req.url));
diff --git a/pages/api/auth/[...nextauth].tsx b/pages/api/auth/[...nextauth].tsx
index 20ce47c692..96200ec75c 100644
--- a/pages/api/auth/[...nextauth].tsx
+++ b/pages/api/auth/[...nextauth].tsx
@@ -113,11 +113,11 @@ export const authOptions: NextAuthOptions = {
createdAt: true,
},
});
- // only send the welcome email if the user was created in the last 10 seconds
+ // only send the welcome email if the user was created in the last 5 minutes
// (this is a workaround because the `isNewUser` flag is triggered when a user does `dangerousEmailAccountLinking`)
if (
user?.createdAt &&
- new Date(user.createdAt).getTime() > Date.now() - 10000
+ new Date(user.createdAt).getTime() > Date.now() - 300000
) {
sendEmail({
subject: "Welcome to Dub.sh!",