fix(ui): hold recovery codes before the activation request
Activation ends the session while the reply is on its way, so a 401 elsewhere in the page could leave before the codes arrived. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9137e0948
commit
0e4e8cc37e
1 file changed
+11
-3
+11
-3
@@ -196,12 +196,20 @@ function bindMfa() {
|
||||
$('#mfaEnroll').addEventListener('submit', (event) => {
|
||||
event.preventDefault();
|
||||
attempt(status, async () => {
|
||||
const reply = await withReauth(() => api('/api/auth/enroll/confirm', {
|
||||
// Activation ends this session while the reply is on its way: a request
|
||||
// from elsewhere in the page can get a 401 and leave before it lands,
|
||||
// taking the codes with it. So the page is held before the POST.
|
||||
holdCodes();
|
||||
let reply;
|
||||
try {
|
||||
reply = await withReauth(() => api('/api/auth/enroll/confirm', {
|
||||
method: 'POST',
|
||||
body: { code: $('#mfaCode').value.trim() },
|
||||
}));
|
||||
// This session has just ended, and the page must not leave with the codes.
|
||||
holdCodes();
|
||||
} catch (error) {
|
||||
releaseCodes();
|
||||
throw error;
|
||||
}
|
||||
$('#mfaEnroll').hidden = true;
|
||||
$('#mfaQr').removeAttribute('src');
|
||||
$('#mfaKey').value = '';
|
||||
|
||||
Reference in new issue
Block a user