DEV-1037: feat(login): migrate to unified auth flow#237
Open
hcarneiro wants to merge 5 commits intoprojects/DEV-908-unified-loginfrom
Open
DEV-1037: feat(login): migrate to unified auth flow#237hcarneiro wants to merge 5 commits intoprojects/DEV-908-unified-loginfrom
hcarneiro wants to merge 5 commits intoprojects/DEV-908-unified-loginfrom
Conversation
Replaces the legacy /v1/auth/third-party endpoint (which is being removed from the API as part of DEV-908) with the same unified sign-in URL the Fliplet Login widget and VS Code extension now use. The allow-list on the API already includes http://localhost:9001/callback so no server-side change is needed for the CLI path. Contract change: the callback URL now receives ?token=<token>&user=... instead of ?auth_token=<token>. Parse the token with url.parse(...).query so we handle any additional params the API may append. Drive-by fixes to the callback handler surfaced while testing: - Multi-org users no longer hard-fail. The previous code rejected any user belonging to more than one organization with "You belong to multiple organizations." Now we pick the first organization by default and print a note telling the user how to switch afterwards via `fliplet list-organizations` + `fliplet organization <id>`. - Every error path now writes an HTTP response to the browser AND calls process.exit(1). The old code left connections hanging, which caused the browser to retry and fire the callback handler twice — leading to the "multiple organizations" error printing twice. package-lock.json: drift from 7.0.0 to 7.0.1 (matches package.json, unrelated to this change). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The organizations module captured auth_token at require-time. When `fliplet login` runs as a single process — sign-in happens via a browser callback AFTER the module was loaded — the captured token was whatever was in configstore at startup (null on first login), and the subsequent getOrganizationsList() call failed with "You must login first with: fliplet login". Moving the user/auth_token lookup inside the function makes it read the up-to-date configstore value every call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New developer documentation for the Fliplet.Auth SDK (fliplet-auth package). Covers: - signIn / signOut / currentUser / isSignedIn / getToken / onChange - Common patterns (gated screens, profile display, sign-out button, authenticated API requests, reacting to auth state changes) - What Fliplet.Auth does NOT do (no user creation from apps, no app-specific user data management) Also registers the doc in the API-Documentation.md index under the alphabetical "Auth" entry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Review pass against references/style-guide.md and references/dev-docs-rules.md:
- Add YAML frontmatter with description field (required for dev docs)
- Remove all horizontal rules (---) per style guide
- Promote the "can't create users from apps" caveat to a <p class="warning">
callout in "Before you start" — previously buried at the end
- Disambiguate Fliplet.Auth vs Fliplet.User vs data source login on
first use rather than only mentioning at the end
- First signIn() example includes .catch() so copy-paste is safe
- Make Error rejection cases explicit with exact message strings
- Remove `region` from the documented currentUser() shape (internal
detail derived from token prefix, not part of public contract)
- Clarify signIn() vs currentUser() return-shape asymmetry inline at
the point of discovery rather than in a separate "gotchas" section
- Add "if server-side logout fails" behaviour note under signOut()
- All code examples guard against null token / missing user per
dev-docs-rules ("Code examples must match documented constraints")
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a link to the Fliplet.Auth reference doc in the JS API → Libraries section of the sidebar, alphabetically between Core and Communicate, with the NEW label. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1/auth/third-partyendpoint with the unified/v1/auth/login?return=callback&callback=http://localhost:9001/callbackcontract?token=<token>(new contract) instead of?auth_token=<token>using proper URL parsingfliplet organization <id>to switchprocess.exit(1)(prevents browser retries that triggered duplicate errors)Test plan
node fliplet-login.js(orfliplet loginif linked) — verify browser opens to unified sign-in page🤖 Generated with Claude Code