page.tsx
1,845 bytes
| 1 | import { Github, GitCompareArrows } from 'lucide-react'; |
|---|---|
| 2 | import Link from 'next/link'; |
| 3 | import { redirect } from 'next/navigation'; |
| 4 | import { auth, signIn } from '@/auth'; |
| 5 | import { Button } from '@/components/ui/button'; |
| 6 | import { isGithubAuthConfigured } from '@/lib/env'; |
| 7 | |
| 8 | export const dynamic = 'force-dynamic'; |
| 9 | |
| 10 | export default async function SignInPage() { |
| 11 | const session = await auth(); |
| 12 | if (session?.user) redirect('/history'); |
| 13 | |
| 14 | return ( |
| 15 | <div className="container flex min-h-[70vh] items-center justify-center py-12"> |
| 16 | <div className="w-full max-w-sm space-y-6 text-center"> |
| 17 | <GitCompareArrows className="mx-auto h-8 w-8 text-primary" /> |
| 18 | <div className="space-y-2"> |
| 19 | <h1 className="font-display text-2xl font-semibold tracking-tight"> |
| 20 | Sign in to Roundtable |
| 21 | </h1> |
| 22 | <p className="text-sm text-muted-foreground"> |
| 23 | Keep every question and verdict in one place. |
| 24 | </p> |
| 25 | </div> |
| 26 | {isGithubAuthConfigured ? ( |
| 27 | <form |
| 28 | action={async () => { |
| 29 | 'use server'; |
| 30 | await signIn('github', { redirectTo: '/history' }); |
| 31 | }} |
| 32 | > |
| 33 | <Button type="submit" className="w-full"> |
| 34 | <Github className="h-4 w-4" /> Continue with GitHub |
| 35 | </Button> |
| 36 | </form> |
| 37 | ) : ( |
| 38 | <p className="text-sm text-muted-foreground"> |
| 39 | GitHub sign-in is not configured on this deployment. You can still ask questions without |
| 40 | an account. |
| 41 | </p> |
| 42 | )} |
| 43 | <p className="text-xs text-muted-foreground"> |
| 44 | Prefer no account?{' '} |
| 45 | <Link href="/debate" className="text-primary hover:underline"> |
| 46 | Ask a question without saving an account |
| 47 | </Link> |
| 48 | . |
| 49 | </p> |
| 50 | </div> |
| 51 | </div> |
| 52 | ); |
| 53 | } |
| 54 | |