Skip to content

feat: auto-trigger login when not authenticated#5

Merged
tonychang04 merged 1 commit intomainfrom
feat/auto-login-on-requireauth
Feb 26, 2026
Merged

feat: auto-trigger login when not authenticated#5
tonychang04 merged 1 commit intomainfrom
feat/auto-login-on-requireauth

Conversation

@tonychang04
Copy link
Copy Markdown
Contributor

@tonychang04 tonychang04 commented Feb 26, 2026

Summary

  • Extracts reusable performOAuthLogin() into src/lib/auth.ts from the duplicated OAuth logic in login.ts
  • Makes requireAuth() async — if no credentials exist, it seamlessly starts the browser OAuth flow instead of throwing an error
  • Updates all 48 command files to await requireAuth()

Test plan

  • npm run build passes
  • Run any command without being logged in → browser opens for OAuth, command continues after auth
  • Run any command while already logged in → works as before (no login prompt)
  • insforge login still works standalone with intro/outro messaging
  • insforge login --email still works for email/password flow

🤖 Generated with Claude Code

Instead of throwing an error telling users to run `insforge login`,
commands now seamlessly start the OAuth login flow inline and continue
after authentication. Extracts reusable performOAuthLogin() into auth.ts
and makes requireAuth() async with auto-login fallback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tonychang04 tonychang04 merged commit 7e60b1a into main Feb 26, 2026
1 check failed
CarmenDou added a commit that referenced this pull request May 2, 2026
- --json mode: print authorize URL to stderr instead of stdout so the
  final JSON result stays parseable; browser still opens and polling
  still runs (review #1).
- spawn wizard with stdio: 'ignore' on all three streams in --json mode
  so unconsumed pipes can't block on long wizard output (review #5).
- fetchPosthogConnection accepts an optional AbortSignal so polling can
  cancel a hung request when the deadline or user signal fires (review #3).
- All three posthog API fetches go through a fetchWithTimeout helper
  that gives each request a 30s timeout and respects an optional caller
  signal (reviews #6, #7).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant