main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import { createRouteHandlerClient } from '@supabase/auth-helpers-nextjs'
import { cookies } from 'next/headers'
import { NextRequest, NextResponse } from 'next/server'
export async function GET(request: NextRequest) {
const requestUrl = new URL(request.url)
const code = requestUrl.searchParams.get('code')
const next = requestUrl.searchParams.get('next') ?? '/success'
if (code) {
const supabase = createRouteHandlerClient({ cookies })
try {
// Exchange the code for a session
const { data, error } = await supabase.auth.exchangeCodeForSession(code)
if (error) {
console.error('Auth callback error:', error)
// Redirect to auth page with error
return NextResponse.redirect(
`${requestUrl.origin}/auth?error=auth_callback_error&error_description=${encodeURIComponent(error.message)}`
)
}
if (data.session) {
// Successfully authenticated
console.log('User authenticated successfully:', data.user?.email)
// Check if this is an appointment booking verification
const userMetadata = data.user?.user_metadata
if (userMetadata?.appointment_booking) {
// Redirect to success page for appointment booking
return NextResponse.redirect(`${requestUrl.origin}/success`)
} else {
// Redirect to admin dashboard or default page
return NextResponse.redirect(`${requestUrl.origin}/kunden-projekte`)
}
}
} catch (error) {
console.error('Unexpected error in auth callback:', error)
return NextResponse.redirect(
`${requestUrl.origin}/auth?error=unexpected_error&error_description=${encodeURIComponent('Ein unerwarteter Fehler ist aufgetreten.')}`
)
}
}
// If no code, redirect to auth page
return NextResponse.redirect(`${requestUrl.origin}/auth`)
}

43
app/auth/page.tsx Normal file
View File

@@ -0,0 +1,43 @@
"use client";
import { useSearchParams } from 'next/navigation'
import EmailAuth from '@/components/MagicLinkAuth'
import { AlertCircle } from 'lucide-react'
import { colors } from '@/lib/colors'
export default function AuthPage() {
const searchParams = useSearchParams()
const error = searchParams.get('error')
const errorDescription = searchParams.get('error_description')
return (
<div className="min-h-screen flex items-center justify-center p-4">
<div className="w-full max-w-md">
{/* Error Display */}
{error && (
<div className="mb-6 p-4 rounded-xl border-2 border-red-500 bg-red-50">
<div className="flex items-center space-x-3 mb-2">
<AlertCircle className="w-5 h-5 text-red-600" />
<h3 className="font-semibold text-red-700">
Authentifizierungsfehler
</h3>
</div>
<p className="text-sm text-red-600 mb-2">
{errorDescription || 'Ein Fehler ist bei der Authentifizierung aufgetreten.'}
</p>
<div className="text-xs text-red-500">
<p><strong>Fehler:</strong> {error}</p>
{error === 'otp_expired' && (
<p className="mt-2">
💡 <strong>Tipp:</strong> Der E-Mail-Link ist abgelaufen. Bitte fordern Sie einen neuen Link an.
</p>
)}
</div>
</div>
)}
<EmailAuth />
</div>
</div>
)
}