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.

Opt out of welcome flow for folks with invites + some minor bug fixes

Steven Tey955dd8b86bee
diff --git a/components/app/domains/domain-configuration.tsx b/components/app/domains/domain-configuration.tsx
index 77e37abca8..189387868f 100644
--- a/components/app/domains/domain-configuration.tsx
+++ b/components/app/domains/domain-configuration.tsx
@@ -126,7 +126,7 @@ export default function DomainConfiguration({
<p className="mt-5 text-sm">
Note: for TTL, if <InlineSnippet>86400</InlineSnippet> is not
available, set the highest value possible. Also, domain propagation
- can take up to an hour.
+ can take anywhere between 1 hour to 12 hours.
</p>
</div>
</div>
diff --git a/components/app/modals/invite-teammate-modal.tsx b/components/app/modals/invite-teammate-modal.tsx
index cf49301930..b2a3899ac4 100644
--- a/components/app/modals/invite-teammate-modal.tsx
+++ b/components/app/modals/invite-teammate-modal.tsx
@@ -83,6 +83,7 @@ function InviteTeammateModal({
name="email"
id="email"
placeholder="[email protected]"
+ autoFocus
autoComplete="off"
required
value={email}
diff --git a/lib/middleware/app.ts b/lib/middleware/app.ts
index 2cb376aa27..1328d1446d 100644
--- a/lib/middleware/app.ts
+++ b/lib/middleware/app.ts
@@ -2,6 +2,7 @@ import { NextRequest, NextResponse } from "next/server";
import { getToken } from "next-auth/jwt";
import { parse } from "#/lib/middleware/utils";
import { UserProps } from "../types";
+import { conn } from "../planetscale";
export default async function AppMiddleware(req: NextRequest) {
const { path } = parse(req);
@@ -30,7 +31,16 @@ export default async function AppMiddleware(req: NextRequest) {
new Date(session?.user?.createdAt).getTime() > Date.now() - 10000 &&
path !== "/welcome"
) {
- return NextResponse.redirect(new URL("/welcome", req.url));
+ // check if the user has an existing project invite, if yes, we skip the onboarding flow
+ const existingInvite = await conn
+ ?.execute("SELECT projectId FROM ProjectInvite WHERE email = ?", [
+ session.email,
+ ])
+ .then((res) => res.rows[0] as { projectId: string } | undefined);
+
+ if (!existingInvite) {
+ return NextResponse.redirect(new URL("/welcome", req.url));
+ }
// if the path is /login or /register, redirect to "/"
} else if (path === "/login" || path === "/register") {
diff --git a/pages/app/settings.tsx b/pages/app/settings.tsx
index dccebb090c..7b23ef53c2 100644
--- a/pages/app/settings.tsx
+++ b/pages/app/settings.tsx
@@ -94,7 +94,7 @@ export default function PersonalSettings() {
<div className="border-b border-red-600" />
<div className="flex items-center justify-end p-3 sm:px-10">
- <div className="w-32">
+ <div>
<Button
text="Delete Account"
variant="danger"