user creation and invites
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user