error toast. could not load user profile
This commit is contained in:
@@ -65,12 +65,12 @@ export default async function AdminLayout({
|
|||||||
</Link>
|
</Link>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<Link href="/admin/embed" className="w-full">
|
<Link href="/admin/embed" className='w-full'>
|
||||||
<SidebarMenuButton>
|
<SidebarMenuButton>
|
||||||
<Code2 />
|
<Code2 />
|
||||||
Embed
|
Embed
|
||||||
</SidebarMenuButton>
|
</SidebarMenuButton>
|
||||||
</Link>
|
</Link>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
<SidebarMenuItem>
|
<SidebarMenuItem>
|
||||||
<SidebarMenuButton>
|
<SidebarMenuButton>
|
||||||
|
|||||||
@@ -57,6 +57,14 @@ export async function updateUser(
|
|||||||
const userId = session.user.id;
|
const userId = session.user.id;
|
||||||
|
|
||||||
try {
|
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) {
|
if (password && password.trim().length > 0) {
|
||||||
// In a real app, you would hash the password here
|
// In a real app, you would hash the password here
|
||||||
const stmt = db.prepare(
|
const stmt = db.prepare(
|
||||||
@@ -70,9 +78,6 @@ export async function updateUser(
|
|||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('Failed to update user:', error);
|
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.' };
|
return { success: false, error: 'Failed to update user profile due to a server error.' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user