Skip to content

Commit 04867a4

Browse files
committed
Update 2FA handling and API endpoint for recovery key generation
- Improved the logic for checking if 2FA is enabled by verifying the text content of the element. - Updated the API endpoint for generating recovery keys to reflect the new structure.
1 parent 4b04ddc commit 04867a4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

frontend/static/js/user.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ class UserModule {
250250
}
251251

252252
// Check if 2FA is enabled and require code
253-
const twoFactorEnabled = document.getElementById('twoFactorEnabled').classList.contains('enabled');
253+
const twoFactorElement = document.getElementById('twoFactorEnabled');
254+
const twoFactorEnabled = twoFactorElement && twoFactorElement.textContent.trim() === 'Enabled';
254255
if (twoFactorEnabled && !twoFactorCode) {
255256
this.showStatus(statusElement, 'Please enter your 2FA code', 'error');
256257
return;
@@ -262,7 +263,7 @@ class UserModule {
262263
requestBody.two_factor_code = twoFactorCode;
263264
}
264265

265-
const response = await fetch('./api/auth/recovery-key/generate', {
266+
const response = await fetch('./auth/recovery-key/generate', {
266267
method: 'POST',
267268
headers: { 'Content-Type': 'application/json' },
268269
body: JSON.stringify(requestBody)

0 commit comments

Comments
 (0)