From f92c79ac6073dda556b33ecf5732449d120d844a Mon Sep 17 00:00:00 2001 From: Dmytro Stanchiev Date: Tue, 19 Aug 2025 04:27:13 -0400 Subject: [PATCH] implement auth error page and moved auth-related pages to /auth path --- src/app/auth/error/page.tsx | 31 +++++++++++++++++++++++++++++ src/app/{ => auth}/signin/page.tsx | 6 +++--- src/app/{ => auth}/signout/page.tsx | 0 src/app/components/sign-in.tsx | 6 +++--- src/app/page.tsx | 6 +++--- src/auth.ts | 8 +++++--- 6 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 src/app/auth/error/page.tsx rename src/app/{ => auth}/signin/page.tsx (98%) rename src/app/{ => auth}/signout/page.tsx (100%) diff --git a/src/app/auth/error/page.tsx b/src/app/auth/error/page.tsx new file mode 100644 index 0000000..acbce09 --- /dev/null +++ b/src/app/auth/error/page.tsx @@ -0,0 +1,31 @@ +"use client" + +import { Button } from "@/components/ui/button" +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" +import Link from "next/link" +import { useSearchParams } from "next/navigation" + +export default function AuthErrorPage() { + const searchParams = useSearchParams() + const errorMessage = searchParams.get('error') + + return ( +
+ + + Error + + +
+ {errorMessage} +
+
+ +
+
+
+
+ ) +} diff --git a/src/app/signin/page.tsx b/src/app/auth/signin/page.tsx similarity index 98% rename from src/app/signin/page.tsx rename to src/app/auth/signin/page.tsx index 304f473..a6791a3 100644 --- a/src/app/signin/page.tsx +++ b/src/app/auth/signin/page.tsx @@ -6,7 +6,7 @@ import Link from "next/link" export default async function SignInPage() { const session = await auth() - + // If already signed in, redirect to home if (session?.user) { redirect("/") @@ -32,7 +32,7 @@ export default async function SignInPage() { Continue with Authentik - +
Continue without signing in @@ -42,4 +42,4 @@ export default async function SignInPage() {
) -} \ No newline at end of file +} diff --git a/src/app/signout/page.tsx b/src/app/auth/signout/page.tsx similarity index 100% rename from src/app/signout/page.tsx rename to src/app/auth/signout/page.tsx diff --git a/src/app/components/sign-in.tsx b/src/app/components/sign-in.tsx index 3d6c66f..e7621ca 100644 --- a/src/app/components/sign-in.tsx +++ b/src/app/components/sign-in.tsx @@ -32,9 +32,9 @@ export default function SignIn() { } return ( - )} diff --git a/src/auth.ts b/src/auth.ts index 74b1faa..46ec624 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -25,9 +25,11 @@ const config = { adapter: DrizzleAdapter(db), providers, pages: { - signIn: "/signin", - signOut: "/signout", + signIn: "/auth/signin", + signOut: "/auth/signout", + error: "/auth/error", }, trustHost: true, } satisfies NextAuthConfig; -export const { handlers, signIn, signOut, auth }: NextAuthResult = NextAuth(config); +export const { handlers, signIn, signOut, auth }: NextAuthResult = + NextAuth(config);