feat(api): accept recovery codes as second factor and let users regenerate them
Enabling TOTP returns ten codes that are shown once. Disabling TOTP and regenerating codes require the password plus a current code. Closes #40 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
dbea42e7a5
commit
7b063d2cd8
12 files changed
+510
-123
No files matched your search
@@ -44,6 +44,16 @@
|
||||
button && (button.disabled = true);
|
||||
try {
|
||||
const res = await api.request({ method: form.dataset.method || "post", url, data: body });
|
||||
if (form.dataset.showCodes !== undefined && res.data?.recovery_codes) {
|
||||
const out = form.querySelector("[data-recovery-output]");
|
||||
const list = out.querySelector("[data-recovery-list]");
|
||||
list.replaceChildren(
|
||||
...res.data.recovery_codes.map((c) => Object.assign(document.createElement("li"), { textContent: c })),
|
||||
);
|
||||
for (const el of form.elements) el.disabled = true;
|
||||
out.hidden = false;
|
||||
return;
|
||||
}
|
||||
if (res.data?.status === "totp_required" && totpStep) {
|
||||
form.querySelector('[data-step="password"]').hidden = true;
|
||||
totpStep.hidden = false;
|
||||
|
||||
Reference in new issue
Block a user