diff --git a/src/app/admin/layout.tsx b/src/app/admin/layout.tsx
index f7ca5d4..311fbc6 100644
--- a/src/app/admin/layout.tsx
+++ b/src/app/admin/layout.tsx
@@ -65,12 +65,12 @@ export default async function AdminLayout({
-
-
-
- Embed
-
-
+
+
+
+ Embed
+
+
diff --git a/src/lib/actions/user.ts b/src/lib/actions/user.ts
index 6aab8d0..c2a947c 100644
--- a/src/lib/actions/user.ts
+++ b/src/lib/actions/user.ts
@@ -57,6 +57,14 @@ export async function updateUser(
const userId = session.user.id;
try {
+ // Check if another user with the same email exists
+ const existingUserStmt = db.prepare('SELECT id FROM users WHERE email = ? AND id != ?');
+ const existingUser = existingUserStmt.get(email, userId);
+
+ if (existingUser) {
+ return { success: false, error: 'Email already in use by another account.' };
+ }
+
if (password && password.trim().length > 0) {
// In a real app, you would hash the password here
const stmt = db.prepare(
@@ -70,9 +78,6 @@ export async function updateUser(
return { success: true };
} catch (error: any) {
console.error('Failed to update user:', error);
- if (error.code === 'SQLITE_CONSTRAINT_UNIQUE') {
- return { success: false, error: 'Email already in use by another account.' };
- }
return { success: false, error: 'Failed to update user profile due to a server error.' };
}
}