feat: Refactor user management to replace email with username across the application

This commit is contained in:
2025-07-28 22:25:23 +02:00
parent 6fc2e6703b
commit 07b4af5f24
14 changed files with 298 additions and 96 deletions

View File

@@ -78,7 +78,7 @@ async function updateUserHandler(req, { params }) {
if (error.message.includes("already exists")) {
return NextResponse.json(
{ error: "A user with this email already exists" },
{ error: "A user with this username already exists" },
{ status: 409 }
);
}

View File

@@ -27,9 +27,9 @@ async function createUserHandler(req) {
const data = await req.json();
// Validate required fields
if (!data.name || !data.email || !data.password) {
if (!data.name || !data.username || !data.password) {
return NextResponse.json(
{ error: "Name, email, and password are required" },
{ error: "Name, username, and password are required" },
{ status: 400 }
);
}
@@ -53,7 +53,7 @@ async function createUserHandler(req) {
const newUser = await createUser({
name: data.name,
email: data.email,
username: data.username,
password: data.password,
role: data.role || "user",
is_active: data.is_active !== undefined ? data.is_active : true
@@ -68,7 +68,7 @@ async function createUserHandler(req) {
if (error.message.includes("already exists")) {
return NextResponse.json(
{ error: "A user with this email already exists" },
{ error: "A user with this username already exists" },
{ status: 409 }
);
}