Skip to content

Unify RoutingAuth login callbacks; reuse AuthUIProviders factories#119

Merged
FlorianKirmaier merged 1 commit into
mainfrom
refactor/auth-callbacks
Jun 14, 2026
Merged

Unify RoutingAuth login callbacks; reuse AuthUIProviders factories#119
FlorianKirmaier merged 1 commit into
mainfrom
refactor/auth-callbacks

Conversation

@FlorianKirmaier

Copy link
Copy Markdown
Contributor

Follow-up to the RoutingAuth prototype — the two rough edges flagged in #116: inconsistent callbacks and inline-provider duplication.

Callbacks

  • onLogin now fires for every login method. It already fired for OAuth2 and username/password; this adds it for dummy and defaultUser, so the hook is consistent.
  • onError stays the OAuth2 error handler. It returns a Response (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), and dummy/defaultUser can't fail. Documented as such rather than forced everywhere.

De-duplication

RoutingAuth no longer reimplements the OAuth2/basic providers inline. New additive overloads on AuthUIProviders carry the success/error handling, and RoutingAuth reuses 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: RoutingAuth shrank ~50 lines, and the login behavior lives in one place.

No API churn beyond the additive overloads; RoutingAuth is unreleased (from #116), so this needs no separate CHANGELOG entry.

Verified: :jpro-auth:routing and :jpro-auth:example compile; demo runs (-Psample=routing-auth); no inline providers remain.

🤖 Generated with Claude Code

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>
@FlorianKirmaier FlorianKirmaier merged commit 861aa4e into main Jun 14, 2026
2 of 3 checks passed
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