fix: clear reset secrets and isolate recovery tests
This commit is contained in:
1 parent
63db81e498
commit
62a23fb04c
2 files changed
+35
-18
No files matched your search
+16
-2
@@ -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(); }}
|
||||
/>
|
||||
<button className="btn-primary" style={{ width: '100%' }} onClick={handleResetPassword}>{t('auth.resetPassword')}</button>
|
||||
<button type="button" className="auth-forgot-link" onClick={() => setAuthMode('login')}>
|
||||
<button type="button" className="auth-forgot-link" onClick={returnToLogin}>
|
||||
{t('auth.backToLogin')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user