From 62a23fb04cbb6bc932a861db46279f322b64e25a Mon Sep 17 00:00:00 2001
From: lezi-fun <177434121+lezi-fun@users.noreply.github.com>
Date: Thu, 13 Aug 2026 15:24:04 +0800
Subject: [PATCH] fix: clear reset secrets and isolate recovery tests
---
components/Modals.js | 18 ++++++++++++++++--
test/api.test.js | 35 +++++++++++++++++++----------------
2 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/components/Modals.js b/components/Modals.js
index 4a68c4d..326dbec 100644
--- a/components/Modals.js
+++ b/components/Modals.js
@@ -38,7 +38,13 @@ export default function Modals({ modal, onClose, reportPostId }) {
if (modal === 'register') {
API.getCaptcha().then((c) => setRegCaptcha(c)).catch(() => {});
}
- if (modal !== 'login') setAuthMode('login');
+ if (modal !== 'login') {
+ setAuthMode('login');
+ setResetEmail('');
+ setResetRecoveryCode('');
+ setResetPassword('');
+ setResetPasswordConfirm('');
+ }
}, [modal]);
if (!modal) return null;
@@ -91,6 +97,14 @@ export default function Modals({ modal, onClose, reportPostId }) {
}
};
+ const returnToLogin = () => {
+ setAuthMode('login');
+ setResetEmail('');
+ setResetRecoveryCode('');
+ setResetPassword('');
+ setResetPasswordConfirm('');
+ };
+
const handleRegister = async () => {
if (!regUsername.trim() || !regEmail.trim() || !regPassword) { toast('请填写完整信息', 'warning'); return; }
if (regPassword.length < 6) { toast('密码至少6位', 'warning'); return; }
@@ -169,7 +183,7 @@ export default function Modals({ modal, onClose, reportPostId }) {
onKeyDown={(e) => { if (e.key === 'Enter') handleResetPassword(); }}
/>
-