Skip to content

Commit 6583b42

Browse files
committed
fix: MFA challenge UI improvements
- Simplify test assertion to expect 404 when MFA is disabled in playwright-test profile - Remove unnecessary CSRF header from GET request to /user/mfa/status - Add noscript fallback message on webauthn challenge page
1 parent f618d70 commit 6583b42

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

playwright/tests/mfa/mfa-challenge.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,8 @@ test.describe('MFA', () => {
6868
maxRedirects: 0,
6969
});
7070

71-
// Should not return 200 for unauthenticated request
72-
// Expect redirect to login (302/303) or error (401/403) or 404 (MFA disabled)
73-
expect([302, 303, 401, 403, 404]).toContain(response.status());
71+
// MFA is disabled in playwright-test profile, so endpoint returns 404
72+
expect(response.status()).toBe(404);
7473
});
7574
});
7675
});

src/main/resources/static/js/user/webauthn-manage.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,7 @@ async function updateMfaStatusUI() {
271271
if (!container || !badgesEl) return;
272272

273273
try {
274-
const response = await fetch('/user/mfa/status', {
275-
headers: { [csrfHeader]: csrfToken }
276-
});
274+
const response = await fetch('/user/mfa/status');
277275

278276
if (response.status === 404) {
279277
// MFA feature disabled — silently hide

src/main/resources/templates/user/mfa/webauthn-challenge.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ <h5><i class="bi bi-shield-lock me-2"></i>Additional Verification Required</h5>
4242
</div>
4343
</section>
4444

45+
<noscript>
46+
<div class="container my-5">
47+
<div class="alert alert-warning text-center">
48+
JavaScript is required for passkey verification. Please enable JavaScript in your browser.
49+
</div>
50+
</div>
51+
</noscript>
52+
4553
<script type="module" th:src="@{/js/user/mfa-webauthn-challenge.js}"></script>
4654
</div>
4755
</body>

0 commit comments

Comments
 (0)