Files
gridpilot.gg/apps/website/app/api/auth/login/route.ts
2025-12-07 18:38:03 +01:00

26 lines
714 B
TypeScript

import { NextResponse } from 'next/server';
import { getAuthService } from '@/lib/auth';
export async function POST(request: Request) {
try {
const body = await request.json();
const { email, password } = body;
if (!email || !password) {
return NextResponse.json(
{ error: 'Email and password are required' },
{ status: 400 }
);
}
const authService = getAuthService();
const session = await authService.loginWithEmail({ email, password });
return NextResponse.json({ success: true, session });
} catch (error) {
return NextResponse.json(
{ error: error instanceof Error ? error.message : 'Login failed' },
{ status: 401 }
);
}
}