Auth Package Extraction And Auth Flow Refactor #2
Reference in New Issue
Block a user
No description provided.
Delete Branch "auth-package"
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?
Decouple authentication into reusable
@local/authpackage and unify auth flowSummary
This merge request extracts authentication concerns into a standalone
@local/authpackage and refactors the blog application to consume it as a dependency. Login and registration are unified into a singleAuthPage, token handling is centralized, and the blog app’s auth lifecycle is now driven entirely by the shared auth service.The primary objective is to enforce a clear separation between authentication (identity, tokens, session state) and application-level user models (Author), enabling reuse across future frontends and services.
Key Changes
1. New
@local/authpackageIntroduces a reusable authentication library with:
AuthProvideranduseAuthhooktokenStoreAuthUsermodel shared across appsPackaged with explicit React peer dependencies for safe consumption.
2. Unified Auth UI (
AuthPage)AuthPagecomponent.modeswitching (login/register).3. Centralized token & API handling
Removes ad-hoc token management from the blog app.
All API clients are now created via a shared Axios factory with:
Authorizationheader injection401responsesBlog and Auth services now use the same, consistent client behavior.
4. Blog app refactor to consume auth package
Blog app now wraps itself with the shared
AuthProvider.Existing
AuthorProvideris refactored to:Authordata (/authors/me) on auth state changesRemoves login/register/logout logic from the blog domain entirely.
5. Routing and view simplification
loginandregisterviews.authview with explicit mode handling.open_auth(mode)semantics.6. Type model alignment
AuthorModelnow extendsAuthUserinstead of duplicating identity fields.Why this change
Migration Notes
AuthProviderfrom@local/authand provideauthBaseUrl.login,register,logout) are no longer available and should not be referenced.authinstead oflogin/register.Risk & Impact
Follow-ups (out of scope)
@local/auth.AuthPagestyles into a themeable layer.auth-packageto Auth Package Extraction And Auth Flow Refactor