commit 946f0db40a3be135b8db0c7bd171ff1e6aa979ac
parent 7211ef70ab0950656c4a0e4585a6d70b981fd41a
Author: anon <anon@example.com>
Date: Fri, 6 Nov 2026 03:35:23 +0000
Preserve account controls in the browser page source
Diffstat:
4 files changed, 93 insertions(+), 12 deletions(-)
diff --git a/TODO.md b/TODO.md
@@ -261,13 +261,18 @@ rewriting this document does not close them.
cold recovery without duplicate refunds. November 5: the related reservation,
live-admin and open-shop edit checks pass. This corrects the obsolete test
expectation; no game behavior changed. See [admin edit semantics](docs/admin.md).
-- [ ] **Keep account UI changes in the browser source when publishing.**
+- [x] **Keep account UI changes in the browser source when publishing.**
November 5: publishing the door-observation client exposed existing drift
between `client/browser/index.html` and the checked-in served page: regeneration
would remove the password-change form and other account fixes. The door bundle
preserves the served page. Reconcile the source with those existing features,
regenerate normally and pass the account UI regressions so future client
publications preserve them without a manual page restoration.
+ November 5: the source now retains password changes, empty passwords and the
+ existing account-form fixes. Normal page generation/publication reproduces
+ the served page byte-for-byte. Source account/control/loading checks,
+ publisher regressions and native live-session password changes pass; see
+ [account source and publication](docs/browser-accounts.md#source-and-publication).
- [x] **Repair the admin browser scenario's adopted-player fixture.**
The fixture now claims its visitor through the current account endpoint and
keeps the rotated browser token. `TestAdminBrowser` passes through player
diff --git a/client/browser/index.html b/client/browser/index.html
@@ -54,7 +54,9 @@
#account-choices button { display: block; width: 100%; margin: 8px 0; }
#account-choices button[hidden] { display: none; }
#account-form input { box-sizing: border-box; display: block; width: 100%; margin-top: 6px; padding: 8px; }
+ #account-form label[hidden] { display: none; }
#account-error { color: #ffb0a0; }
+ #account-error.success { color: #b9d8b0; }
#account-error:empty { display: none; }
</style>
<div id="game-surface">
@@ -106,6 +108,7 @@
<fieldset id="account-choices" disabled>
<button id="create-button" type="button">Create character from scratch</button>
<button id="claim-button" type="button" hidden>Adopt this visitor</button>
+ <button id="password-button" type="button" hidden>Change password</button>
<button id="login-button" type="button">Log in to an existing character</button>
</fieldset>
<form id="account-form" hidden>
@@ -137,8 +140,7 @@
</select></label>
</fieldset>
<label>Player name <input id="account-name" name="name" autocomplete="username" maxlength="254" required></label>
- <p>4-12 letters or digits; at least four initial letters, digits only at the end. Other characters are removed and capitalization is adjusted.</p>
- <label>Password <input id="account-password" name="password" type="password" autocomplete="current-password" maxlength="1024" required></label>
+ <label><span id="account-password-label">Password</span> <input id="account-password" name="password" type="password" autocomplete="current-password" maxlength="1024"></label>
<button id="account-back" type="button">Back</button>
<button id="account-submit" type="submit"></button>
</fieldset>
@@ -962,6 +964,7 @@ show();
const accountFields = document.querySelector('#account-fields');
const creationFields = document.querySelector('#creation-fields');
const claimButton = document.querySelector('#claim-button');
+ const passwordButton = document.querySelector('#password-button');
const creationBreed = document.querySelector('#creation-breed');
const creationSex = document.querySelector('#creation-sex');
const creationHead = document.querySelector('#creation-head');
@@ -979,14 +982,22 @@ show();
};
creationSex.onchange = updateCreationHeads;
- // Keep the three account flows separate and clear abandoned credentials on Back.
+ // Keep account flows separate and clear abandoned credentials on Back.
for (const [action, title, description] of [
['create', 'Create character', 'Start a new level-1 character in your side\'s training grounds. Named characters remain available through Log in.'],
['claim', 'Adopt this visitor', 'Keep this character, including its equipment and progress, with a name and password.'],
- ['login', 'Log in', 'Switch to an existing character using its name and password.']
+ ['login', 'Log in', 'Switch to an existing character using its name and password.'],
+ ['password', 'Change password', '']
]) {
document.querySelector('#' + action + '-button').onclick = () => {
accountAction = action;
+ accountError.textContent = '';
+ accountError.classList.remove('success');
+ const changingPassword = action === 'password';
+ document.querySelector('#account-name').disabled = changingPassword;
+ document.querySelector('#account-name').parentElement.hidden = changingPassword;
+ document.querySelector('#account-password-label').textContent = changingPassword ? 'New password' : 'Password';
+ document.querySelector('#account-description').hidden = changingPassword;
accountChoices.hidden = true;
accountForm.hidden = false;
creationFields.hidden = creationFields.disabled = action !== 'create';
@@ -995,7 +1006,7 @@ show();
(action === 'create' && !claimButton.hidden ? ' Adopt this visitor first if you want to return to it later.' : '');
document.querySelector('#account-submit').textContent = title;
document.querySelector('#account-password').autocomplete = action === 'login' ? 'current-password' : 'new-password';
- document.querySelector(action === 'create' ? '#creation-breed' : '#account-name').focus();
+ document.querySelector(changingPassword ? '#account-password' : action === 'create' ? '#creation-breed' : '#account-name').focus();
};
}
document.querySelector('#account-back').onclick = () => {
@@ -1015,7 +1026,8 @@ show();
accountAction = '';
document.querySelector('#account-name').value = document.querySelector('#account-password').value = '';
accountError.textContent = '';
- claimButton.hidden = true;
+ claimButton.hidden = passwordButton.hidden = true;
+ accountError.classList.remove('success');
try {
const response = await fetch('browser-account');
if (!response.ok) { accountError.textContent = await response.text(); return; }
@@ -1025,6 +1037,7 @@ show();
creationBreed.value = '1';
creationBreed.onchange();
claimButton.hidden = !player.visitor;
+ passwordButton.hidden = !player.adopted;
accountChoices.disabled = false;
} catch (error) {
accountError.textContent = 'Could not load player details. Open Options again to retry.';
@@ -1045,8 +1058,18 @@ show();
}
try {
const response = await fetch('browser-account/' + accountAction, {method: 'POST', body: values});
- if (response.ok) { location.reload(); return; }
- accountError.textContent = await response.text();
+ if (response.ok) {
+ if (accountAction !== 'password') { location.reload(); return; }
+ accountForm.hidden = true;
+ accountChoices.hidden = false;
+ accountAction = '';
+ document.querySelector('#account-password').value = '';
+ passwordButton.focus();
+ accountError.classList.add('success');
+ accountError.textContent = 'Password changed.';
+ } else {
+ accountError.textContent = await response.text();
+ }
} catch (error) {
accountError.textContent = 'Could not contact the server. Please try again.';
}
diff --git a/client/tests/browser_accounts.mjs b/client/tests/browser_accounts.mjs
@@ -12,6 +12,8 @@ function accountPage() {
value = '';
style = {};
dataset = {};
+ parentElement = {hidden: false};
+ classList = {add() {}, remove() {}};
close() { this.open = false; }
focus() { this.focused = true; }
replaceChildren(...children) { this.children = children; this.value = String(children[0]?.value ?? ''); }
@@ -52,13 +54,14 @@ function response(status, body) {
const heads = [{mesh: 40681, breed: 1, sex: 2, race: 1}, {mesh: 40629, breed: 1, sex: 3, race: 1},
{mesh: 40111, breed: 4, sex: 1, race: 1}];
-test('Options offers three explicit flows with credentials hidden until a choice', async () => {
+test('Options offers visitor account flows with credentials hidden until a choice', async () => {
const page = accountPage();
page.replies.push(response(200, {name: 'Visitor1', visitor: true, heads}));
await page.open();
assert.equal(page.element('#claim-button').hidden, false);
+ assert.equal(page.element('#password-button').hidden, true);
assert.equal(page.element('#account-choices').disabled, false);
assert.equal(page.element('#account-form').hidden, true);
assert.match(page.element('#account-current').textContent, /Playing as Visitor1/);
@@ -66,17 +69,45 @@ test('Options offers three explicit flows with credentials hidden until a choice
assert.equal(page.requests[0].url, 'browser-account');
});
-test('a named player can create or log in with adoption hidden', async () => {
+test('an adopted player can change password with adoption hidden', async () => {
const page = accountPage();
- page.replies.push(response(200, {name: 'Alice', visitor: false, heads}));
+ page.replies.push(response(200, {name: 'Alice', visitor: false, adopted: true, heads}));
await page.open();
assert.equal(page.element('#claim-button').hidden, true);
+ assert.equal(page.element('#password-button').hidden, false);
assert.equal(page.element('#account-choices').disabled, false);
assert.equal(page.element('#account-current').textContent, 'Playing as Alice.');
});
+for (const password of ['updated password', '']) {
+ test(`password change accepts ${password ? 'a new password' : 'an empty password'} without reloading`, async () => {
+ const page = accountPage();
+ page.choose('password');
+ page.element('#account-password').value = password;
+ page.replies.push(response(204, ''));
+
+ await page.submit();
+
+ assert.equal(page.requests[0].url, 'browser-account/password');
+ assert.equal(page.requests[0].options.body.get('password'), password);
+ assert.deepEqual(page.reloads, []);
+ assert.equal(page.element('#account-form').hidden, true);
+ assert.equal(page.element('#account-choices').hidden, false);
+ assert.equal(page.element('#account-password').value, '');
+ assert.equal(page.element('#account-error').textContent, 'Password changed.');
+ assert.equal(page.element('#password-button').focused, true);
+
+ // Choosing another flow restores the ordinary name/password fields.
+ page.choose('login');
+ assert.equal(page.element('#account-name').disabled, false);
+ assert.equal(page.element('#account-name').parentElement.hidden, false);
+ assert.equal(page.element('#account-password-label').textContent, 'Password');
+ assert.equal(page.element('#account-error').textContent, '');
+ });
+}
+
for (const action of ['create', 'claim', 'login']) {
test(`${action} posts exact credentials and reloads after success despite a session replacement notification`, async () => {
const page = accountPage();
diff --git a/docs/browser-accounts.md b/docs/browser-accounts.md
@@ -22,6 +22,28 @@ also offers the original breed/sex/head, build, height, profession and side
choices. A successful login loads that character; a failed submission leaves
the current player usable.
+## Source and publication
+
+Maintain the account UI in `client/browser/index.html`. The page target in
+`client/Makefile.wasm` copies it to `client/build/wasm/web/index.html`, and
+`tools/client/publish_wasm.py` substitutes the matching bundle's download sizes
+before publishing it to `server/assets/client/index.html`. Page-only changes
+reuse the existing compressed executable.
+
+The November 5 reconciliation restores the served password-change flow and
+empty-password support to that source. Normal page generation and publication
+reproduce the existing served page byte-for-byte; only the build metadata's
+source identity changes in the published bundle. No server account behavior
+or executable bytes change.
+
+All 13 source account checks, 74 control checks, the loading scenario and three
+publisher tests pass. The new password-flow checks fail against the prior
+source. `TestBrowserPasswordOptions` passes in 13.32 seconds against the
+regenerated bundle: visitor eligibility, creation, Back, nonempty and empty
+password changes, unchanged browser credential and uninterrupted game stream.
+The success message was visually inspected. Logs are under
+`local/alpha-account-source/`; native captures are under `local/password-options/`.
+
## Account state and transactions
Private `characters.password_salt` and `password_hash` columns store a random