fix(dev): seed the mobile OAuth client so dev sign-in works #149
No reviewers
Labels
No labels
dependencies
major
security-pin
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
trails-cool/trails!149
Loading…
Reference in a new issue
No description provided.
Delete branch "seed-mobile-oauth-client"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Signing in from the mobile app against a local journal fails:
journal.oauth_clientsis empty on any fresh dev database.Cause
seedOAuthClient("trails-cool-mobile", "trailscool://auth/callback", true)is called insideserver.listen()inapps/journal/server.ts:102. But journal's scripts are:So the client is registered in production only. Mobile sign-in has never been able to work in dev without someone inserting the row by hand.
Fix
Seed it in
scripts/seed.ts, which bothpnpm dev:fullandpnpm dev:resetrun. The insert isonConflictDoNothing, so it's idempotent and leaves the production path inserver.tsas the source of truth for deployed instances.Verification
Against a local stack, with the row deleted to simulate a fresh DB:
pnpm db:seed/oauth/authorize?client_id=trails-cool-mobile&…400 invalid_client302 → /auth/login?returnTo=…/oauth/authorize?client_id=bogus&…400 invalid_client400 invalid_client(still rejected)End-to-end: sign-in from the Android emulator completes and lands on the Map tab.
pnpm typecheck14/14,pnpm test12/12,pnpm lint14/14.🤖 Generated with Claude Code
Signing in from the mobile app against a local journal failed with: {"error":"invalid_client", "error_description":"Unknown client or redirect URI"} journal.oauth_clients was empty. seedOAuthClient("trails-cool-mobile", …) is called inside server.listen() in apps/journal/server.ts, but that file only runs under `pnpm start`; dev uses `react-router dev`. So the client is registered in production and never in dev, and mobile sign-in could not work on any fresh dev database. Seeding it in scripts/seed.ts fixes it for every dev environment, since both `pnpm dev:full` and `pnpm dev:reset` run that script. The insert is onConflictDoNothing, so it stays idempotent alongside the production path, which remains the source of truth for deployed instances. Verified against a local stack: with the row absent, /oauth/authorize returns 400 invalid_client; after `pnpm db:seed` the same request returns 302 to /auth/login with the correct returnTo, and an unknown client_id is still rejected. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>