feat: Refactor user management to replace email with username across the application
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user