you continue telling me that you identify the issue and that is now fixe
This commit is contained in:
@@ -57,6 +57,7 @@ export async function updateUser(
|
||||
const userId = session.user.id;
|
||||
|
||||
try {
|
||||
// Check if the new email is already in use by another user
|
||||
const existingUserStmt = db.prepare('SELECT id FROM users WHERE email = ? AND id != ?');
|
||||
const existingUser = existingUserStmt.get(email, userId);
|
||||
|
||||
@@ -64,12 +65,15 @@ export async function updateUser(
|
||||
return { success: false, error: 'Email already in use by another account.' };
|
||||
}
|
||||
|
||||
// Determine if a new password was provided
|
||||
if (password && password.trim().length > 0) {
|
||||
// If a new password is provided, update name, email, and password
|
||||
const stmt = db.prepare(
|
||||
'UPDATE users SET name = ?, email = ?, password = ? WHERE id = ?'
|
||||
);
|
||||
stmt.run(name, email, password, userId);
|
||||
} else {
|
||||
// If no new password, update only name and email
|
||||
const stmt = db.prepare('UPDATE users SET name = ?, email = ? WHERE id = ?');
|
||||
stmt.run(name, email, userId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user