Skip to content

Commit 66ae1d2

Browse files
tridgeclaude
andcommitted
webadmin: don't put the Generate button on the login page
LoginForm.passphrase and AdminAddForm.passphrase are both named "passphrase", so WTForms renders both with id="passphrase". The add-form Generate-button hook used getElementById('passphrase'), which matched the login form too — a passphrase generator showed up on the login page, which makes no sense there. Scope attachAddFormGenerator() to the form.admin-add-form on the admin list page (the class was already on that <form>); the login page has no such form, so the button no longer appears there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3e335a1 commit 66ae1d2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

webadmin/static/admin-add.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,18 @@
124124
return btn;
125125
}
126126

127-
// Add-form variant: single "passphrase" field. Used on
128-
// /admin/add via the admin_list.html "Add a new entry" form.
127+
// Add-form variant: single "passphrase" field. Scoped to the
128+
// admin "Add a new entry" form (admin_list.html), NOT the login
129+
// form — both fields are named "passphrase" so WTForms gives them
130+
// the same id, but a Generate button has no business on the login
131+
// page.
129132
function attachAddFormGenerator() {
130-
var pw = document.getElementById('passphrase');
133+
var form = document.querySelector('form.admin-add-form');
134+
if (!form) {
135+
return;
136+
}
137+
var pw = form.querySelector('#passphrase')
138+
|| form.querySelector('input[name="passphrase"]');
131139
if (!pw || pw.dataset.generatorAttached) {
132140
return;
133141
}

0 commit comments

Comments
 (0)