diff --git a/src/handlers/accounts.ts b/src/handlers/accounts.ts index 1cfaf8c..bbd586a 100644 --- a/src/handlers/accounts.ts +++ b/src/handlers/accounts.ts @@ -240,42 +240,6 @@ export async function handleGetProfile(request: Request, env: Env, userId: strin return jsonResponse(toProfile(user, env)); } -// PUT /api/accounts/profile -export async function handleUpdateProfile(request: Request, env: Env, userId: string): Promise { - const storage = new StorageService(env.DB); - const user = await storage.getUserById(userId); - if (!user) return errorResponse('User not found', 404); - - let body: { name?: string; email?: string }; - try { - body = await request.json(); - } catch { - return errorResponse('Invalid JSON', 400); - } - - if (typeof body.name === 'string') { - user.name = body.name.trim() || user.name; - } - if (typeof body.email === 'string') { - const normalized = body.email.trim().toLowerCase(); - if (!normalized) return errorResponse('Email is required', 400); - user.email = normalized; - } - user.updatedAt = new Date().toISOString(); - - try { - await storage.saveUser(user); - } catch (error) { - const msg = error instanceof Error ? error.message.toLowerCase() : String(error).toLowerCase(); - if (msg.includes('unique') || msg.includes('constraint')) { - return errorResponse('Email already registered', 409); - } - throw error; - } - - return handleGetProfile(request, env, userId); -} - // POST /api/accounts/keys export async function handleSetKeys(request: Request, env: Env, userId: string): Promise { const storage = new StorageService(env.DB);