Auth / Author Flow Hardening and Client Separation #1

Merged
aetos merged 4 commits from jwt into main 2025-12-13 13:15:21 +00:00

4 Commits

Author SHA1 Message Date
d61415236a bumped up version to 0.3.0 2025-12-13 18:42:58 +05:30
80992f89ad added AUTH_BASE_URL in .drone.yml 2025-12-13 18:38:28 +05:30
8fe75b161b disabled changing username 2025-12-13 18:11:55 +05:30
c23145f338 feat(auth): separate auth and blog API clients and integrate author auto-creation
## Summary
Refactored the authentication flow to correctly separate traffic between the
Auth service and Blog service. Added post-registration author creation and
switched all `/auth/*` calls to the dedicated `auth` Axios client.

## Changes
### AuthProvider
- Replaced `api.post('/auth/register')` with `auth.post('/register')`
- Replaced `api.post('/auth/login')` with `auth.post('/login')`
- Added automatic author creation after user registration (`POST /authors`)
- Switched user identity lookup from `api.get('/auth/me')` to `auth.get('/me')`
- Replaced `/authors/{id}` lookup with `/authors/me`
- Updated imports to use `{ api, auth }`

### Axios Client Layer
- Introduced a new `auth` Axios instance using `VITE_AUTH_BASE_URL`
- Added shared token attachment and 401 handling logic
- Applied interceptors to both `auth` and `api` clients
- Removed inline auth logic from `api.ts`

### Types
- Added `VITE_AUTH_BASE_URL` to `vite-env.d.ts`

## Impact
- Correctly routes authentication traffic to the Auth microservice
- Ensures an Author document is created automatically after registration
- Simplifies identity loading via `/authors/me`
- Improves token handling consistency across both services
2025-12-11 21:00:13 +05:30