Unify RoutingAuth login callbacks; reuse AuthUIProviders factories#119
Merged
Conversation
onLogin now fires for every login method (added for dummy and defaultUser); RoutingAuth's inline OAuth2/basic providers are removed in favour of new callback-accepting AuthUIProviders overloads (createOAuth2 with success/error handlers, createBasicProvider/dummy with an onSuccess hook). onError stays the OAuth2 error handler; the username/password form still shows errors inline. Co-Authored-By: Claude Opus 4.8 (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.
Follow-up to the
RoutingAuthprototype — the two rough edges flagged in #116: inconsistent callbacks and inline-provider duplication.Callbacks
onLoginnow fires for every login method. It already fired for OAuth2 and username/password; this adds it fordummyanddefaultUser, so the hook is consistent.onErrorstays the OAuth2 error handler. It returns aResponse(rendered at the redirect URL), which only fits the redirect-based OAuth2 flow. The username/password form shows failures inline (better UX than navigating away), anddummy/defaultUsercan't fail. Documented as such rather than forced everywhere.De-duplication
RoutingAuthno longer reimplements the OAuth2/basic providers inline. New additive overloads onAuthUIProviderscarry the success/error handling, andRoutingAuthreuses them:createOAuth2(provider, session, button, onSuccess, onError)createBasicProvider(provider, session, onSuccess, redirectUrl)dummy(user, session, redirectUrl, onSuccess)Existing factory signatures are unchanged (the new ones are overloads), so nothing downstream breaks. Net result:
RoutingAuthshrank ~50 lines, and the login behavior lives in one place.No API churn beyond the additive overloads;
RoutingAuthis unreleased (from #116), so this needs no separate CHANGELOG entry.Verified:
:jpro-auth:routingand:jpro-auth:examplecompile; demo runs (-Psample=routing-auth); no inline providers remain.🤖 Generated with Claude Code