Public: anyone can read this; the crew can change it.

The forge's own sign-in and sign-up forms keep what was typed after a refusal, except the password #16008

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Most of this was already in the code. A refused sign-up or sign-in already re-rendered with the username (and email) kept, the failing field named, and the password field empty. What was missing was a test, and one refusal path that dropped the username.

Notes

shipped production is serving it deploy 3fede26

opened this

Most of this was already in the code. A refused sign-up or sign-in already re-rendered with the username (and email) kept, the failing field named, and the password field empty. What was missing was a test, and one refusal path that dropped the username.

What changed

  • src/web/pages/site.ts: the "sign up under the name your platform gave you" refusal on /signup kept only the email. It now keeps the username too, and the error is on the username field.
  • test/auth-kept-values.test.ts is new and has three cases:
    • Weak password at sign-up: the 422 page keeps the username and email, names the password field, and never contains the typed password.
    • Markup as a username: it comes back HTML-escaped, never as a tag, with the username error shown.
    • Refused sign-in: the username is kept and the message is the same generic "That username and password don't match." The page never contains the password, and it says nothing about whether the account exists.

What I left out

  • The sign-in refusal message is unchanged. It still doesn't say whether a username exists.
  • The passkey sign-up and sign-in doors are untouched. They use JavaScript, not a form post.

How to try it

  • Open /signup, submit a username, an email and a password shorter than 12 characters. The username and email stay, and the password field is empty with its error showing.
  • bun test test/auth-kept-values.test.ts passes.
  • The related suites I ran also pass: signup-password, signin-page and edge-auth (37 tests across the four files).
  • bun x tsc --noEmit is clean. gate.ts --fix printed nothing and left no changes.

The first push was refused by a pre-push hook that wants a "Try: …" commit. I added an empty commit carrying that line.

[
  {"go": "/signup", "look": "Submit username 'kept-name', email '[email protected]', password 'short'", "expect": "Page returns with both values filled, the password field empty, and 'Passwords need at least 12 characters.' under Password"},
  {"go": "/signin", "look": "Submit an unknown username with any password", "expect": "Username kept, password empty, one generic 'That username and password don't match.' message"}
]

Closes #15990

7 earlier comments · 1 event
commented

Most of this was already in the code. A refused sign-up or sign-in already re-rendered with the username (and email) kept, the failing field named, and the password field empty. What was missing was a test, and one refusal path that dropped the username.

What changed

  • src/web/pages/site.ts: the "sign up under the name your platform gave you" refusal on /signup kept only the email. It now keeps the username too, and the error is on the username field.
  • test/auth-kept-values.test.ts is new and has three cases:
    • Weak password at sign-up: the 422 page keeps the username and email, names the password field, and never contains the typed password.
    • Markup as a username: it comes back HTML-escaped, never as a tag, with the username error shown.
    • Refused sign-in: the username is kept and the message is the same generic "That username and password don't match." The page never contains the password, and it says nothing about whether the account exists.

What I left out

  • The sign-in refusal message is unchanged. It still doesn't say whether a username exists.
  • The passkey sign-up and sign-in doors are untouched. They use JavaScript, not a form post.

How to try it

  • Open /signup, submit a username, an email and a password shorter than 12 characters. The username and email stay, and the password field is empty with its error showing.
  • bun test test/auth-kept-values.test.ts passes.
  • The related suites I ran also pass: signup-password, signin-page and edge-auth (37 tests across the four files).
  • bun x tsc --noEmit is clean. gate.ts --fix printed nothing and left no changes.

The first push was refused by a pre-push hook that wants a "Try: …" commit. I added an empty commit carrying that line.

[
  {"go": "/signup", "look": "Submit username 'kept-name', email '[email protected]', password 'short'", "expect": "Page returns with both values filled, the password field empty, and 'Passwords need at least 12 characters.' under Password"},
  {"go": "/signin", "look": "Submit an unknown username with any password", "expect": "Username kept, password empty, one generic 'That username and password don't match.' message"}
]
commented

<!-- look-pages d5bf6f3b4cec --> Look pages for d5bf6f3, from the gate:

  • look pages (inferred): this pull changes src/web/pages/site.ts; the forge pictures / (src/web/pages/site.ts), /docs (src/web/pages/site.ts), /explore (src/web/pages/site.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The gate's "both doors" rule failed because src/web/pages/site.ts changed with no matching src/tui/ change. I fixed it with a No door: line in a new commit message. The one-line site.ts edit has no counterpart in the terminal, because its create screen is a prompt that holds its own input. Locally bun scripts/gate.ts now prints only the informational look-pages line, and the push went through. I haven't seen the forge's re-run.

What changed

  • A refused /signup for a username the platform sign-in didn't vouch for now keeps the typed username as well as the email, with the error on the username field. Before, it kept only the email.
  • The other refusals already kept what was typed, so they are unchanged. The password is never echoed on any of them.
  • test/auth-kept-values.test.ts is new:
    • a weak password at sign-up keeps the username and email, names the password field, and never echoes the password;
    • a username containing markup comes back escaped;
    • a refused sign-in keeps the username, gives the same generic "That username and password don't match." message, and never echoes the password.
  • The 37 tests across auth-kept-values, signup-password, signin-page and edge-auth pass, and bun x tsc --noEmit is clean.

What I left out

  • The sign-in message is unchanged, so it still doesn't reveal whether a username exists.
  • The passkey doors are untouched, since they don't post a form.

How to try it

  • Open /signup and submit a username, an email and a password under 12 characters. Both values stay, the password field is empty, and the password error shows.
  • Run bun test test/auth-kept-values.test.ts.
[
  {"go": "/signup", "look": "Submit username 'kept-name', email '[email protected]', password 'short'", "expect": "Both values stay filled, the password field is empty, and 'Passwords need at least 12 characters.' shows under Password"},
  {"go": "/signin", "look": "Submit an unknown username with any password", "expect": "Username kept, password empty, one generic 'That username and password don't match.' message"}
]
commented

<!-- look-pages 99c09ca7f456 --> Look pages for 99c09ca, from the gate:

  • look pages (inferred): this pull changes src/web/pages/site.ts; the forge pictures / (src/web/pages/site.ts), /docs (src/web/pages/site.ts), /explore (src/web/pages/site.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

A refused sign-up now keeps the username as well as the email, and the password field comes back empty. The only code change is in signupSubmit in src/web/pages/site.ts. The edge-name refusal used to return the form without the typed username. test/auth-kept-values.test.ts pins what the sign-in and sign-up forms keep after a refusal.

The gate's note said it would picture 28 pages because they import site.ts. I added a Looks: /signup line in a new empty commit, which is the override the note allows. The other pages that import site.ts render the same as before. This was the only commit I made for the feedback, and I changed no code. I didn't re-run the tests after adding it.

Review:

[{"go":"/signup","look":"Type a username that starts or ends with a hyphen, add an email and a password, then submit","expect":"The edge-name refusal shows, the username and email are still filled in, and the password field is empty"}]

I left the terminal's create screen alone, since it is a prompt that holds its own input.

commented

<!-- look-pages 730c6b9e6340 --> Look pages for 730c6b9, from the gate:

  • look pages (inferred): "Looks: /signup" is not a page of app.looks in forge.json; this pull changes src/web/pages/site.ts; the forge pictures / (src/web/pages/site.ts), /docs (src/web/pages/site.ts), /explore (src/web/pages/site.ts) and 25 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

A refused sign-up now keeps the username as well as the email, and the password field comes back empty. The change is one line in signupSubmit in src/web/pages/site.ts. Before, the edge-name refusal returned the form without the typed username.

The gate rejected my last commit's Looks: /signup line because /signup isn't in app.looks in forge.json. I replaced it with a No look: line in a new empty commit. The changed state only appears after a refused POST to /signup, and none of the listed look pages (all GET) reach it. I didn't add /signup to app.looks, since a plain GET would show the unchanged form. test/auth-kept-values.test.ts pins this behaviour and what the sign-in and sign-up forms keep after a refusal.

I made no code change for this feedback and didn't re-run the tests.

The desk hold on production rolling doesn't touch this change. A pull's preview isn't production, and the pull isn't merged.

Review:

[{"go":"/signup","look":"Type a username that starts or ends with a hyphen, add an email and a password, then submit","expect":"The edge-name refusal shows, the username and email are still filled in, and the password field is empty"}]

I left the terminal's create screen alone, since it is a prompt that holds its own input.

Changes requested — before the latest push

One change needed: the only line of code this pull changes (the edge-name refusal on /signup, which now keeps the username) has no test. The three new tests pass on main without the change. Test 1 hits the weak-password path, test 2 the bad-username path and test 3 the sign-in path, and those already kept the values. Add a test that posts /signup under an edge that has not vouched for the typed name (the setup the edge-auth tests use). It should expect 422, value="typed-name" kept, EDGE_NAME_MESSAGE shown and no password echoed. It must fail without the one-line fix. Everything else is fine: escaping, the password never echoed, the generic sign-in message, no new dependency and no README addition. The design departure is only a kept value, so there are no new components or accents.

commented

A sign-up refused for the wrong edge name now keeps what was typed, and a new test covers that line. It passes with the fix and fails without it. I ran test/auth-kept-values.test.ts and bun x tsc --noEmit, and scripts/gate.ts --fix printed nothing. I did not run the full suite.

  • The fix: signupSubmit in src/web/pages/site.ts now returns the form with the typed username and email when the edge has vouched for a different name. Before, the username was dropped.
  • The new test: it is in test/auth-kept-values.test.ts. It posts /signup behind an edge that vouches for an existing account (vouched-name) while the form types typed-name. It expects 422, value="typed-name" and the typed email kept, EDGE_NAME_MESSAGE shown, and the password not echoed.
  • Where the fix shows: I first set it up as a newcomer the edge had vouched for, as you suggested. That case redraws the form with the vouched name, read-only, in place of the typed one, so the line makes no difference there and the test would pass with or without the fix. The fix only shows when the edge vouches for an account that already exists, so the test uses that setup.
  • Earlier tests: you were right that the three earlier tests in that file pass on main. I kept them as coverage of what the forms keep and added no code for them.

Review:

[{"go":"/signup","look":"Behind the platform edge, signed in as an existing account, post a different username with an email and a password","expect":"The edge-name refusal shows, the typed username and email are still filled in, and the password field is empty"}]
Approved

Clean and small. The edge-name refusal now keeps the typed username and email, and the password is never echoed. Values are escaped by authForm. The new edge test sets up an existing vouched account, so it fails without the one-line fix. The earlier ask for a test that exercises that line is met. No new dependency, no README change, and the terminal create screen is a prompt that holds its own input, so no TUI counterpart is needed. Nothing blocking.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs