From 12024203bee1ca96b4bb2170b1e00c7f16ca879f Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Thu, 5 Mar 2026 01:18:23 +0800 Subject: [PATCH] feat: reorder key assignment logic in handleSetKeys for improved readability --- src/handlers/accounts.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/handlers/accounts.ts b/src/handlers/accounts.ts index f61b0ba..604f63d 100644 --- a/src/handlers/accounts.ts +++ b/src/handlers/accounts.ts @@ -308,15 +308,16 @@ export async function handleSetKeys(request: Request, env: Env, userId: string): return errorResponse('Invalid password', 400); } - if (body.key) user.key = body.key; - if (body.encryptedPrivateKey) user.privateKey = body.encryptedPrivateKey; - if (body.publicKey) user.publicKey = body.publicKey; if (body.key && !looksLikeEncString(body.key)) { return errorResponse('key is not a valid encrypted string', 400); } if (body.encryptedPrivateKey && !looksLikeEncString(body.encryptedPrivateKey)) { return errorResponse('encryptedPrivateKey is not a valid encrypted string', 400); } + + if (body.key) user.key = body.key; + if (body.encryptedPrivateKey) user.privateKey = body.encryptedPrivateKey; + if (body.publicKey) user.publicKey = body.publicKey; user.updatedAt = new Date().toISOString(); await storage.saveUser(user);