Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@ai-sdk/openai": "^1.2.5",
"@ai-sdk/provider": "^1.0.11",
"@ai-sdk/react": "^1.1.23",
"@ai-sdk/openai": "^1.2.7",
"@ai-sdk/provider": "^1.0.12",
"@ai-sdk/react": "^1.1.25",
"@aws-sdk/client-s3": "^3.758.0",
"@aws-sdk/s3-request-presigner": "^3.758.0",
"@browserbasehq/sdk": "^2.4.0",
Expand All @@ -26,7 +26,7 @@
"@novu/headless": "^2.6.6",
"@novu/react": "^2.6.6",
"@prisma/instrumentation": "^6.5.0",
"@tanstack/react-query": "^5.68.0",
"@tanstack/react-query": "^5.69.0",
"@tanstack/react-table": "^8.21.2",
"@tiptap/extension-table": "^2.11.5",
"@tiptap/extension-table-cell": "^2.11.5",
Expand All @@ -40,7 +40,7 @@
"@types/d3": "^7.4.3",
"@uploadthing/react": "^7.3.0",
"@upstash/ratelimit": "^2.0.5",
"ai": "^4.1.61",
"ai": "^4.1.64",
"argon2": "^0.41.1",
"bun": "^1.2.5",
"crypto": "^1.0.1",
Expand All @@ -52,7 +52,7 @@
"ky": "^1.7.5",
"languine": "^3.1.2",
"marked": "^15.0.7",
"next": "^15.3.0-canary.13",
"next": "^15.3.0-canary.14",
"next-auth": "^5.0.0-beta.25",
"next-international": "^1.3.1",
"next-intl": "^3.26.5",
Expand All @@ -61,8 +61,8 @@
"novel": "^1.0.2",
"novu": "^2.6.6",
"nuqs": "^2.4.1",
"playwright-core": "^1.51.0",
"posthog-js": "^1.231.0",
"playwright-core": "^1.51.1",
"posthog-js": "^1.232.0",
"posthog-node": "^4.10.1",
"puppeteer-core": "^24.4.0",
"react": "^19.0.0",
Expand All @@ -81,7 +81,7 @@
"tiptap-markdown": "^0.8.10",
"ts-pattern": "^5.6.2",
"use-debounce": "^10.0.4",
"use-long-press": "^3.2.0",
"use-long-press": "^3.3.0",
"uuid": "^11.1.0",
"xml2js": "^0.6.2",
"yarn": "^1.22.22",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { auth } from "@/auth";
import { getI18n } from "@/locales/server";
import { redirect } from "next/navigation";
import { SecondaryMenu } from "@bubba/ui/secondary-menu";

export default async function Layout({
Expand All @@ -9,11 +7,6 @@ export default async function Layout({
children: React.ReactNode;
}) {
const t = await getI18n();
const session = await auth();

if (!session?.user?.organizationId) {
redirect("/auth");
}

return (
<div className="max-w-[1200px] mx-auto">
Expand Down
4 changes: 2 additions & 2 deletions apps/app/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default function Layout({ children }: { children: React.ReactNode }) {
return <>{children}</>;
}
return <>{children}</>;
}
18 changes: 9 additions & 9 deletions apps/app/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { auth } from "@/auth";
import { redirect } from "next/navigation";

export default async function RootPage() {
const session = await auth();
const session = await auth();

if (!session) {
redirect("/auth");
}
if (!session?.user) {
redirect("/auth");
}

if (session.user?.organizationId) {
redirect(`/${session.user.organizationId}`);
}
if (session.user?.organizationId) {
redirect(`/${session.user.organizationId}`);
}

redirect("/setup");
}
redirect("/setup");
}
58 changes: 29 additions & 29 deletions apps/app/src/components/google-sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ import { signIn } from "next-auth/react";
import { useState } from "react";

export function GoogleSignIn({
inviteCode,
inviteCode,
}: {
inviteCode?: string;
inviteCode?: string;
}) {
const t = useI18n();
const t = useI18n();

const [isLoading, setLoading] = useState(false);
const [isLoading, setLoading] = useState(false);

const handleSignIn = async () => {
setLoading(true);
const handleSignIn = async () => {
setLoading(true);

await signIn("google", {
redirectTo: inviteCode
? `/api/auth/invitation?code=${inviteCode}`
: "/setup",
});
};
await signIn("google", {
redirectTo: inviteCode
? `/api/auth/invitation?code=${inviteCode}`
: "/setup",
});
};

return (
<Button
onClick={handleSignIn}
className="flex h-[40px] w-full space-x-2 px-6 py-4 font-medium active:scale-[0.98]"
>
{isLoading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
<>
<ButtonIcon className="mr-2" isLoading={isLoading}>
<Icons.Google />
</ButtonIcon>
<span>{t("auth.google")}</span>
</>
)}
</Button>
);
return (
<Button
onClick={handleSignIn}
className="flex h-[40px] w-full space-x-2 px-6 py-4 font-medium active:scale-[0.98]"
>
{isLoading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
<>
<ButtonIcon className="mr-2" isLoading={isLoading}>
<Icons.Google />
</ButtonIcon>
<span>{t("auth.google")}</span>
</>
)}
</Button>
);
}
4 changes: 3 additions & 1 deletion apps/app/src/components/magic-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ export function MagicLinkSignIn({ className, inviteCode }: Props) {

await signIn("resend", {
email: email,
redirectTo: inviteCode ? `/api/auth/invitation?code=${inviteCode}` : "/",
redirectTo: inviteCode
? `/api/auth/invitation?code=${inviteCode}`
: "/setup",
})
.then((res) => {
setSent(true);
Expand Down
69 changes: 18 additions & 51 deletions apps/app/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,61 +1,28 @@
import { createI18nMiddleware } from "next-international/middleware";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import { auth } from "@/auth";
import type { Session } from "next-auth";

export const config = {
matcher: [
// Skip auth-related routes
"/((?!api|_next/static|_next/image|favicon.ico|monitoring|ingest).*)",
],
runtime: "nodejs", // Specify the runtime environment as Node.js, since we're using AWS with Postgres.
};
import { NextResponse, type NextRequest } from "next/server";

const I18nMiddleware = createI18nMiddleware({
locales: ["en", "es", "fr", "no", "pt"],
defaultLocale: "en",
urlMappingStrategy: "rewrite",
locales: ["en", "es", "fr", "no", "pt"],
defaultLocale: "en",
urlMappingStrategy: "rewrite",
});

// By invoking auth, we ensure that the session is loaded and we are wrapping the middleware.
// Add any middleware logic here inside the callback.
// See: https://authjs.dev/getting-started/session-management/protecting?framework=Next.js

async function mainMiddleware(request: NextRequest & { auth: Session | null }) {
try {
// If the user is not authenticated, redirect to the auth page
if (!request.auth && request.nextUrl.pathname !== "/auth") {
return NextResponse.redirect(new URL("/auth", request.nextUrl.origin));
}

// Only handle root path redirects
if (request.nextUrl.pathname === "/") {
if (!request.auth) {
return NextResponse.redirect(new URL("/auth", request.nextUrl.origin));
}
export async function middleware(request: NextRequest) {
const response = I18nMiddleware(request);
const nextUrl = request.nextUrl;
const pathnameLocale = nextUrl.pathname.split("/", 2)?.[1];

// If authenticated, let the page handle the redirection
// This way we avoid Prisma in middleware
return NextResponse.next();
}
const pathnameWithoutLocale = pathnameLocale
? nextUrl.pathname.slice(pathnameLocale.length + 1)
: nextUrl.pathname;

const response = I18nMiddleware(request);
const nextUrl = request.nextUrl;
response.headers.set("x-pathname", request.nextUrl.pathname);

const pathnameLocale = nextUrl.pathname.split("/", 2)?.[1];

const pathnameWithoutLocale = pathnameLocale
? nextUrl.pathname.slice(pathnameLocale.length + 1)
: nextUrl.pathname;

response.headers.set("x-pathname", request.nextUrl.pathname);

return response;
} catch (error) {
console.error("Middleware error:", error);
return new NextResponse("Internal Server Error", { status: 500 });
}
return response;
}

export default auth(mainMiddleware);
export const config = {
matcher: [
"/((?!api|_next/static|_next/image|favicon.ico|monitoring|ingest).*)",
],
};
18 changes: 11 additions & 7 deletions apps/portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@
},
"dependencies": {
"@t3-oss/env-nextjs": "^0.12.0",
"better-auth": "^1.1.18",
"next": "^15.2.0",
"better-auth": "^1.2.4",
"next": "^15.3.0-canary.14",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-otp-input": "^3.1.1"
},
"devDependencies": {
"@bubba/ui": "workspace:*",
"@bubba/db": "workspace:*",
"@types/node": "^22.13.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"postcss": "^8.5.2",
"@types/node": "^22.13.10",
"@types/react": "19.0.10",
"@types/react-dom": "19.0.4",
"postcss": "^8.5.3",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.3"
"typescript": "^5.8.2"
},
"resolutions": {
"@types/react": "19.0.10",
"@types/react-dom": "19.0.4"
}
}
2 changes: 1 addition & 1 deletion apps/portal/src/app/[locale]/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function Providers({ children, locale }: ProviderProps) {
{children}
</AnalyticsProvider>
) : (
children
<>{children}</>
)}
</ThemeProvider>
</I18nProviderClient>
Expand Down
Loading