mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
feat: reorder key assignment logic in handleSetKeys for improved readability
This commit is contained in:
@@ -308,15 +308,16 @@ export async function handleSetKeys(request: Request, env: Env, userId: string):
|
|||||||
return errorResponse('Invalid password', 400);
|
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)) {
|
if (body.key && !looksLikeEncString(body.key)) {
|
||||||
return errorResponse('key is not a valid encrypted string', 400);
|
return errorResponse('key is not a valid encrypted string', 400);
|
||||||
}
|
}
|
||||||
if (body.encryptedPrivateKey && !looksLikeEncString(body.encryptedPrivateKey)) {
|
if (body.encryptedPrivateKey && !looksLikeEncString(body.encryptedPrivateKey)) {
|
||||||
return errorResponse('encryptedPrivateKey is not a valid encrypted string', 400);
|
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();
|
user.updatedAt = new Date().toISOString();
|
||||||
|
|
||||||
await storage.saveUser(user);
|
await storage.saveUser(user);
|
||||||
|
|||||||
Reference in New Issue
Block a user