refactor: update MitmServerCard and MitmToolCard to use modalError instead of message for error handling

- Replaced message state with modalError in both components for better error management.
- Removed unused message display logic and adjusted action handling to improve clarity.
- Enhanced error handling in doAction and doDnsAction functions to ignore errors gracefully.
- Updated API call responses to streamline user feedback on actions.
This commit is contained in:
decolua
2026-03-20 12:44:20 +07:00
parent 6af8043f2a
commit c8d2497423
8 changed files with 117 additions and 103 deletions

View File

@@ -146,6 +146,15 @@ async function saveMitmSettings(enabled, password) {
}
}
async function clearEncryptedPassword() {
if (!_updateSettings) return;
try {
await _updateSettings({ mitmSudoEncrypted: null });
} catch (e) {
err(`Failed to clear encrypted password: ${e.message}`);
}
}
async function loadEncryptedPassword() {
if (!_getSettings) return null;
try {
@@ -467,6 +476,7 @@ async function startServer(apiKey, sudoPassword) {
// Detect wrong/missing password — clear cache and stop retry loop
if (!IS_WIN && (msg.includes("incorrect password") || msg.includes("no password was provided"))) {
setCachedPassword(null);
clearEncryptedPassword();
mitmIsRestarting = true; // prevent scheduleMitmRestart from firing
}
});
@@ -603,5 +613,6 @@ module.exports = {
getCachedPassword,
setCachedPassword,
loadEncryptedPassword,
clearEncryptedPassword,
initDbHooks,
};