Skip to content

Identity schema and password-less users (erweb.identities) #1398

Backlog

Description

@athvin

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

  1. Write Drizzle migration 0009 in frontend/drizzle/, generated from schema.ts and never hand-written.
    • Add a new table, erweb.identities:
      • id (ULID)
      • user_id, referencing users, with on delete cascade
      • provider (text; only google for now)
      • subject, the provider's stable id (Google's sub). Never the email address.
      • email_at_link
      • hd_at_link, which is null for Gmail accounts
      • created_at
      • last_login_at
    • Add a unique index on (provider, subject) and an index on user_id.
    • Make users.password_hash nullable.
    • Add users.super_admin_source: a nullable enum of manual or google_domain. Backfill manual for every existing super admin.
    • Add users.terms_accepted_at, a nullable timestamp, used by the signup ticket.
  2. 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".
  3. 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 /reset page copy gains one line: "Signed up with Google? Use Continue with Google instead."
  4. Changing your password (api/auth/password) refuses for a user without a password. Setting a first password is out of scope.
  5. Update the design doc. Bring §2.4 of frontend-design.md up to date with the final columns, and note super_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 = null can'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_resets row.
  • Inserting two identities with the same (provider, subject) fails. Deleting a user deletes its identities.
  • Every existing super admin has super_admin_source = manual after the migration.
  • The src/lib/** coverage floor holds.

Out of scope

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 and meta/.
  • 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.

Activity

  1. added
    post-mvp
    on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    post-mvp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions