implement auth error page and moved auth-related pages to /auth path
This commit is contained in:
31
src/app/auth/error/page.tsx
Normal file
31
src/app/auth/error/page.tsx
Normal file
@@ -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 (
|
||||
<div className="min-h-screen flex items-center justify-center bg-background p-4">
|
||||
<Card className="w-full max-w-md bg-red-400 dark:bg-red-600">
|
||||
<CardHeader className="text-center">
|
||||
<CardTitle className="text-2xl font-bold">Error</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="text-center p-3 bg-background rounded-lg">
|
||||
{errorMessage}
|
||||
</div>
|
||||
<div className="flex flex-row">
|
||||
<Button variant="secondary" asChild>
|
||||
<Link href="/">Go back to Homepage</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -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
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
|
||||
<div className="text-center">
|
||||
<Link href="/" className="text-sm text-muted-foreground hover:underline">
|
||||
Continue without signing in
|
||||
@@ -42,4 +42,4 @@ export default async function SignInPage() {
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -32,9 +32,9 @@ export default function SignIn() {
|
||||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
onClick={() => router.push("/signin")}
|
||||
variant="outline"
|
||||
<Button
|
||||
onClick={() => router.push("/auth/signin")}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
>
|
||||
Sign In
|
||||
|
||||
@@ -143,13 +143,13 @@ export default function HomePage() {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ prompt: aiPrompt })
|
||||
})
|
||||
|
||||
|
||||
if (res.status === 401) {
|
||||
alert('Please sign in to use AI features.')
|
||||
setAiLoading(false)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const data = await res.json()
|
||||
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
@@ -254,7 +254,7 @@ export default function HomePage() {
|
||||
Sign in to unlock AI-powered calendar features
|
||||
</div>
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<a href="/signin">Sign In</a>
|
||||
<a href="/auth/signin">Sign In</a>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user