diff --git a/app/api/events/register/route.ts b/app/api/events/register/route.ts index 7d773d0..d9f4c24 100644 --- a/app/api/events/register/route.ts +++ b/app/api/events/register/route.ts @@ -9,6 +9,8 @@ export async function POST(request: Request) { const body = await request.json(); const { eventId, steamId, carModel, carSkin, teamName } = body; + console.log('Received registration data:', body); + // Validate required fields if (!eventId || !steamId || !carModel) { return NextResponse.json( @@ -17,8 +19,18 @@ export async function POST(request: Request) { ); } - // Convert steamId to number (BIGINT) - const driverGuid = parseInt(steamId); + // Validate steamId format to prevent SQL injection + const steamId = inputSteamId.trim(); // just in case + + if (!/^[0-9]{15,20}$/.test(steamId)) { + return NextResponse.json( + { success: false, error: "Invalid Steam ID format" }, + { status: 400 } + ); + } + + const driverGuid = steamId; + console.log('Parsed driver GUID:', driverGuid); if (isNaN(driverGuid)) { return NextResponse.json( { success: false, error: 'Invalid Steam ID format' }, @@ -28,7 +40,7 @@ export async function POST(request: Request) { // Check if user exists in database const userCheck = await queryOne( - 'SELECT driver_guid FROM users WHERE driver_guid = $1', + 'SELECT driver_guid FROM users WHERE driver_guid = $1;', [driverGuid] ); diff --git a/app/events/[event_id]/page.tsx b/app/events/[event_id]/page.tsx index c2e524c..cc322fc 100644 --- a/app/events/[event_id]/page.tsx +++ b/app/events/[event_id]/page.tsx @@ -4,7 +4,7 @@ import { query } from '@/lib/db'; import { Event, EventRegistration } from '@/types/racing'; import { notFound } from 'next/navigation'; -import { TrophyIcon, MapPinIcon, UsersIcon } from '@/components/ui/icons'; +import { TrophyIcon, MapPinIcon, UsersIcon, ClockIcon, CalendarIcon } from '@/components/ui/icons'; import EventRegistrationForm from '@/components/events/EventRegistrationForm'; async function getEvent(eventId: number): Promise { @@ -51,8 +51,9 @@ export default async function EventDetailPage({ }: { params: Promise<{ id: string }>; }) { - const { id } = await params; - const eventId = parseInt(id); + const { event_id } = await params; + + const eventId = parseInt(event_id, 10); const event: any = await getEvent(eventId); if (!event) { @@ -87,8 +88,8 @@ export default async function EventDetailPage({ {/* Event Info Cards */}
} /> - - + } /> + } />
- OW © 2025 OPENWHEELS.RACING diff --git a/app/rankings/page.tsx b/app/rankings/page.tsx index c39d03b..163e0e4 100644 --- a/app/rankings/page.tsx +++ b/app/rankings/page.tsx @@ -178,7 +178,7 @@ export default async function RankingsPage({ )} - + {driver.driver_name} @@ -188,7 +188,7 @@ export default async function RankingsPage({ - + {driverClass.name}