mfa fixing

This commit is contained in:
2026-08-13 10:40:27 +01:00
parent bc4bbe6e56
commit 6063f95504
22 changed files with 834 additions and 158 deletions
+19 -5
View File
@@ -27,22 +27,26 @@
{{if .has_passkeys}}
<div class="d-grid mb-3">
<button type="button" class="btn btn-outline-primary" id="passkey-btn">
<button type="button" class="btn btn-primary" id="passkey-btn">
<i class="bi bi-fingerprint me-1"></i>Use a passkey / security key
</button>
</div>
{{if .totp_enabled}}<div class="text-center text-muted mb-3">or</div>{{end}}
{{if .totp_enabled}}
<div class="text-center text-muted mb-3">
or <a href="#" id="show-totp-link">use an authenticator app code instead</a>
</div>
{{end}}
{{end}}
{{if .totp_enabled}}
<form method="POST" action="/pymta-manager/login/mfa">
<form method="POST" action="/pymta-manager/login/mfa" id="totp-form" {{if .has_passkeys}}class="d-none"{{end}}>
<input type="hidden" name="next" value="{{.next}}">
<div class="mb-3">
<label for="code" class="form-label">6-digit authenticator code</label>
<input type="text" class="form-control" id="code" name="code" inputmode="numeric" pattern="[0-9]{6}" maxlength="6" required autofocus>
<input type="text" class="form-control" id="code" name="code" inputmode="numeric" pattern="[0-9]{6}" maxlength="6" required {{if not .has_passkeys}}autofocus{{end}}>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary"><i class="bi bi-shield-check me-1"></i>Verify</button>
<button type="submit" class="btn {{if .has_passkeys}}btn-outline-primary{{else}}btn-primary{{end}}"><i class="bi bi-shield-check me-1"></i>Verify</button>
</div>
</form>
{{end}}
@@ -66,6 +70,16 @@
return btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
const showTotpLink = document.getElementById('show-totp-link');
if (showTotpLink) {
showTotpLink.addEventListener('click', function(e) {
e.preventDefault();
document.getElementById('totp-form').classList.remove('d-none');
document.getElementById('code').focus();
this.parentElement.classList.add('d-none');
});
}
const passkeyBtn = document.getElementById('passkey-btn');
if (passkeyBtn) {
passkeyBtn.addEventListener('click', async function() {