wip
This commit is contained in:
26
apps/website/app/api/auth/login/route.ts
Normal file
26
apps/website/app/api/auth/login/route.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
26
apps/website/app/api/auth/signup/route.ts
Normal file
26
apps/website/app/api/auth/signup/route.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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, displayName } = body;
|
||||
|
||||
if (!email || !password || !displayName) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Email, password, and display name are required' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const authService = getAuthService();
|
||||
const session = await authService.signupWithEmail({ email, password, displayName });
|
||||
|
||||
return NextResponse.json({ success: true, session });
|
||||
} catch (error) {
|
||||
return NextResponse.json(
|
||||
{ error: error instanceof Error ? error.message : 'Signup failed' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user