fix: update 2FA support descriptions and improve error handling in TOTP actions

This commit is contained in:
shuaiplus
2026-03-02 22:36:10 +08:00
parent 16a7bcace9
commit 4da5525a1a
7 changed files with 19 additions and 17 deletions
+4 -2
View File
@@ -611,14 +611,16 @@ export default function App() {
async function enableTotpAction(secret: string, token: string) {
if (!secret.trim() || !token.trim()) {
pushToast('error', t('txt_secret_and_code_are_required'));
return;
const error = new Error(t('txt_secret_and_code_are_required'));
pushToast('error', error.message);
throw error;
}
try {
await setTotp(authedFetch, { enabled: true, secret: secret.trim(), token: token.trim() });
pushToast('success', t('txt_totp_enabled'));
} catch (error) {
pushToast('error', error instanceof Error ? error.message : t('txt_enable_totp_failed'));
throw error;
}
}