Repository navigation
Backlog
Labels
post-mvpExpansion after the usable API workflow; no AppExchange prerequisite
Description
Why
Right now a user can only be someone with a password. erweb.users.password_hash is NOT NULL (frontend/src/lib/db/schema.ts:39), and nothing records "this Google account is that user".
Google sign-in needs two things the schema doesn't have:
- a durable link from a Google subject (
sub) to a user; - a user who has no password at all.
We also need to tell apart a super admin granted automatically by domain from one granted by hand, so that the automatic grant can be taken back automatically.
What the user sees
Nothing directly. One visible change: a user who signed up with Google and asks for "Forgot password" is told to sign in with Google instead.
How
- Write Drizzle migration
0009infrontend/drizzle/, generated fromschema.tsand never hand-written.- Add a new table,
erweb.identities:id(ULID)user_id, referencing users, with on delete cascadeprovider(text; onlygooglefor now)subject, the provider's stable id (Google'ssub). Never the email address.email_at_linkhd_at_link, which is null for Gmail accountscreated_atlast_login_at
- Add a unique index on
(provider, subject)and an index onuser_id. - Make
users.password_hashnullable. - Add
users.super_admin_source: a nullable enum ofmanualorgoogle_domain. Backfillmanualfor every existing super admin. - Add
users.terms_accepted_at, a nullable timestamp, used by the signup ticket.
- Add a new table,
- Password login (
frontend/src/app/api/auth/login/route.ts) treats a null hash as a failed login: the same generic 401, the same timing path, and no message saying "this account uses Google". - Password reset (
api/auth/password-reset) still returns the same 202 for a user without a password, so it can't be used to find accounts. It never mints a token for that user. The/resetpage copy gains one line: "Signed up with Google? Use Continue with Google instead." - Changing your password (
api/auth/password) refuses for a user without a password. Setting a first password is out of scope. - Update the design doc. Bring §2.4 of
frontend-design.mdup to date with the final columns, and notesuper_admin_source.
Acceptance criteria
- The migration applies cleanly on PGlite (the functional tier), on the driver tier against a real Postgres, and on a copy of the prod erweb schema. The run against the copy is recorded in the PR.
-
[email protected]'s existing password login still works after the migration (driver tier). - A user with
password_hash = nullcan't log in with any password. The response is indistinguishable from a wrong password. - A reset request for a null-hash user returns 202 and writes no
password_resetsrow. - Inserting two identities with the same
(provider, subject)fails. Deleting a user deletes its identities. - Every existing super admin has
super_admin_source = manualafter the migration. - The
src/lib/**coverage floor holds.
Out of scope
- The OIDC routes (Sign in with Google: the core OIDC flow (start, callback, linking, mock IdP) #1399).
- Letting a Google-only user set a password.
Depends on
Nothing. This ticket blocks #1399, #1402 and #1404.
Where to start
frontend/src/lib/db/schema.ts: users at L34-46, invites at L92-109.frontend/drizzle/for the latest migration andmeta/.frontend/src/app/api/auth/{login,password,password-reset}/route.ts.
Estimate: 0.5 engineer-weeks.
Part of the E31 epic (#1396) (linked as parent). Decisions recorded 2026-11-28 with the owner.
Metadata
Metadata
Assignees
Labels
post-mvpExpansion after the usable API workflow; no AppExchange prerequisite
Activity