mirror of
https://github.com/SkalaraAI/skalara-core.git
synced 2025-04-09 23:20:15 -04:00
27 lines
703 B
TypeScript
27 lines
703 B
TypeScript
import { createRouteHandlerClient } from "@supabase/auth-helpers-nextjs";
|
|
import { cookies } from "next/headers";
|
|
import { NextResponse } from "next/server";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function POST(request: Request) {
|
|
const formData = await request.json();
|
|
const email = String(formData.email);
|
|
const password = String(formData.password);
|
|
const supabase = createRouteHandlerClient({ cookies });
|
|
|
|
const { error } = await supabase.auth.signInWithPassword({
|
|
email,
|
|
password,
|
|
});
|
|
|
|
if (error) {
|
|
return NextResponse.json({ error }, { status: 401 });
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{ message: "Successfully signed in." },
|
|
{ status: 200 }
|
|
);
|
|
}
|