Repository navigation
feat(studio): opt-in remembered accounts on the sign-in page (#388 step 3) - #390
Merged
Merged
Conversation
A signed-in member who opened /login saw the sign-in form again, and a signed-out member's deep link was lost after sign-in. - /login, /forgot-password and /reset-password check the session in beforeLoad (the cached one, so no extra request) and go on to the validated `redirect`, or to /sites. An RFC-0044 authorization request (?client_id=…&sig=…) stays; a playground goes to /sites. /invite is unchanged. - requireSession redirects to /login?redirect=<path+search+hash>. The login route keeps `redirect` only when it is a same-origin path (lib/login-redirect.ts: one linear pass, at most 2 kB, no `//`, `/\`, scheme, backslash or control character). LoginPage goes there after sign-in and sign-up; the OAuth `next` URL still wins. - The session guards move from router.tsx to lib/route-guards.ts. - The email field says autocomplete="username" in sign-in mode, so password managers pair it with the password; sign-up keeps `email` and `new-password`. Tests cover the redirects, the validation (including a 100k-character value) and that sign-out clears the cached session. Refs #388 (steps 1–2) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
Step 3 of #388, like Cloudflare's login profiles. A "Remember this account on this device" choice (off by default) keeps { email, name, lastUsedAt } in localStorage after a successful sign-in: no token, session id, role or user id; at most five per origin, dropped after 30 days unused, validated on every read and guarded against storage that throws. While any are kept, the signed-out /login lists them first (the new AccountChooser block): picking one fills in the email and focuses the password, a Forget button removes one, "Use another account" shows the empty form; ?redirect= and RFC-0044 requests work through it. The user menu adds "Sign out and forget", which forgets only the signed-in member's entry. Sign-up, the setup link and failed sign-ins store nothing; no Clear-Site-Data. Strings in English; the other languages are AI drafts awaiting review. Refs #388 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #388 (step 3)
Base: stacked on #389 (
claude/login-guest-388-f4c8e6, steps 1–2), which was still open when this was pushed. Once #389 merges, this rebases ontomainand its own commit is the only change.Opt-in remembered accounts on Studio's signed-out
/login, like Cloudflare's login profiles.What it does
apps/studio/src/lib/remembered-accounts.ts): one versionedlocalStoragekey per origin,cloudhal.rememberedAccounts.v1.{ email, name, lastUsedAt }and nothing else: no token, session id, role, user id or avatar.nowandstorageare injectable.Checkbox, off by default.AccountChooserblock in@cloudhal/ui, with the description "Choose an account to continue."Avatar, the name and the email. Picking one fills in the email and focuses the password.?redirect=and?client_id&sigwork through the chooser; both are tested.UserMinus) sits under "Sign out" while this browser remembers any account.Clear-Site-Datais sent./invite, setup-token sign-up or reset-password.i18n
auth.*keys inen.ts.pnpm i18n:export/pnpm i18n:import. They await review, and no language is marked reviewed.Docs
docs/start/quickstart.md: what is stored and how to remove it.docs/design/DESIGN.md: the auth template (§2) and theAccountChooserrow in §6.@cloudhal/cli.Design shots
Taken with
pnpm design:shotsat 1440 and 390 px against a localcloudhal studioplus Vite. No sideways scroll and no console errors.Checks
pnpm design:lint: 449 files clean.pnpm size:check: ok.LoginPagewas split so it stays under 150 lines:useRememberedLoginplus small footer, setup-banner and sign-in-extras components.test/remembered-accounts.test.ts(10)test/login-remembered.test.tsx(14: LoginPage + UserMenu)packages/ui/test/account-chooser.test.tsx(1)login-guestandlogin-setuptests.apps/studiovitest suite: 90 files, 1474 tests passed.🤖 Generated with Claude Code