user creation and invites

This commit is contained in:
2025-06-24 16:31:13 -04:00
parent 23c8f468fe
commit a659401bde
32 changed files with 667 additions and 30 deletions

View File

@@ -3,7 +3,14 @@ import { prisma } from '@/lib/prisma';
import bcrypt from 'bcrypt';
export async function POST(req: NextRequest) {
const { email, password, role } = await req.json();
const { email, username, password, role } = await req.json();
const existingUsername = await prisma.user.findUnique({
where: { username },
})
if (existingUsername) {
return new NextResponse('Username already taken', { status: 400 })
}
const existing = await prisma.user.findUnique({ where: { email }});
if (existing) return new NextResponse('User already exists', { status: 400 });
@@ -12,6 +19,7 @@ export async function POST(req: NextRequest) {
const user = await prisma.user.create({
data: {
email,
username,
password: hashed,
role
}