ubiquitous-invention/apps/web
Randall Stillwell 875b1cfc87 auth: case-insensitive emails, Authentik SSO, first-signin workspace provisioning
Three pieces of authentication work that need to land together so OAuth
sign-ins produce a usable session.

* `ensureUserIdByEmail` upserts a `users` row on every OAuth sign-in
  matched case-insensitively on email, then stamps `token.id` with the
  resulting UUID so workspace-scoped tRPC procedures can resolve
  membership. Credentials sign-in already returned the DB id from
  `authorize`; OAuth now does the equivalent.
* `ensureUserHasWorkspace` mints a personal workspace (and `owner`
  member row) on first sign-in for any user that doesn't already
  belong to one, so fresh OAuth accounts don't land in the app with
  no tenant scope. Idempotent; slug collisions retry with a random
  suffix and cap at 5 attempts.
* Migration 0004 adds a `UNIQUE (lower(email))` index on `users` to
  match the lookup pattern and prevent two providers from minting
  rows that differ only in casing. Existing rows are normalized to
  lowercase first; the column-level UNIQUE catches any pre-existing
  duplicates so they get resolved by a human rather than silently
  merged.

Sign-in / sign-up pages add an Authentik SSO button (gated on
`AUTH_AUTHENTIK_*` env vars). Layout switches to GitHub+Google on top
with Authentik full-width below.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-01 23:45:00 -05:00
..
app auth: case-insensitive emails, Authentik SSO, first-signin workspace provisioning 2026-06-01 23:45:00 -05:00
components multi-tenancy: promote workspaces to top-level table 2026-05-06 23:02:55 -05:00
lib auth: case-insensitive emails, Authentik SSO, first-signin workspace provisioning 2026-06-01 23:45:00 -05:00
public docker: ensure apps/web/public exists so web runtime COPY succeeds 2026-04-27 14:46:47 -05:00
server multi-tenancy: promote workspaces to top-level table 2026-05-06 23:02:55 -05:00
styles feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
middleware.ts feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
next-env.d.ts feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
next.config.ts fix(web): import @tasks/ai via workspace alias instead of relative path 2026-04-27 12:57:27 -05:00
package.json fix(web): import @tasks/ai via workspace alias instead of relative path 2026-04-27 12:57:27 -05:00
postcss.config.mjs feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
tailwind.config.ts feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00
tsconfig.json feat: Full project management application scaffold 2026-03-26 22:39:16 -05:00