Initial commit v1

This commit is contained in:
Rolf
2026-03-18 12:37:17 +01:00
commit 4897d3003f
55 changed files with 14241 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { createClient } from '@/lib/supabase/server'
import { NextResponse, type NextRequest } from 'next/server'
export async function GET(request: NextRequest) {
const { searchParams, origin } = new URL(request.url)
const code = searchParams.get('code')
const next = searchParams.get('next') ?? '/dashboard'
if (code) {
const supabase = await createClient()
const { error } = await supabase.auth.exchangeCodeForSession(code)
if (!error) {
return NextResponse.redirect(`${origin}${next}`)
}
}
return NextResponse.redirect(`${origin}/login?error=auth_failed`)
}
+85
View File
@@ -0,0 +1,85 @@
'use client'
import { useState } from 'react'
import { createClient } from '@/lib/supabase/client'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
export default function LoginPage() {
const [email, setEmail] = useState('')
const [submitted, setSubmitted] = useState(false)
const [error, setError] = useState<string | null>(null)
const [loading, setLoading] = useState(false)
async function handleSubmit(e: React.FormEvent) {
e.preventDefault()
setLoading(true)
setError(null)
const supabase = createClient()
const { error } = await supabase.auth.signInWithOtp({
email,
options: {
emailRedirectTo: `${window.location.origin}/auth/confirm`,
shouldCreateUser: false, // invite-only: only existing users can log in
},
})
if (error) {
setError(error.message)
} else {
setSubmitted(true)
}
setLoading(false)
}
if (submitted) {
return (
<div className="flex min-h-screen items-center justify-center p-6">
<div className="w-full max-w-sm space-y-4 text-center">
<div className="text-4xl"></div>
<h1 className="text-2xl font-bold">Check your email</h1>
<p className="text-muted-foreground">
We sent a magic link to <strong>{email}</strong>. Tap the link to
sign in.
</p>
</div>
</div>
)
}
return (
<div className="flex min-h-screen items-center justify-center p-6">
<div className="w-full max-w-sm space-y-6">
<div className="space-y-2 text-center">
<div className="text-4xl"></div>
<h1 className="text-2xl font-bold">MulliganMates</h1>
<p className="text-muted-foreground">Sign in to track your round</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
placeholder="you@example.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
autoComplete="email"
autoFocus
/>
</div>
{error && <p className="text-destructive text-sm">{error}</p>}
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Sending…' : 'Send magic link'}
</Button>
</form>
</div>
</div>
)
}