[v0.8.0] Improving Authentication + Upload Feature
Pre-release
Pre-release
Release Notes — v0.8.0
HAPI-246 Improving Authentication + Upload Feature
Bug Fixes
- Session not persisting after login — Session data is now explicitly saved before the request continues, preventing race conditions where the session was lost between requests.
- Session not persisting after register — Session is now built from the user model and saved before the response is sent.
- Email confirmation wiping session — Confirm-email now updates the session in place instead of destroying it, preserving auth state.
- Signout recreating session — Replaced
sessionStore.destroy()withsession.destroy()to properly prevent express-session from auto-saving a new session after signout. - Ghost sessions accumulating in store — Auth middleware now destroys the temporary ghost session created during token-based session restoration, preventing store bloat.
- Subscription doc ID not resolving on nested snapshots — Document subscription lookup now falls back to
_doc._idwhen the top-level_idis not available. - Socket emitting non-serializable payloads —
SubscriptionIOnow calls.toObject()when available before emitting data over the socket. cookieStoreunavailable in some environments — Client auth now falls back todocument.cookiewhencookieStoreis not defined.
New Features
- File Upload (
AJAX.upload) — Newupload(endpoint, file, fields, options)method on the client AJAX service for sendingmultipart/form-datarequests with optional extra fields and upload progress tracking. - Authenticated File Upload (
AJAX.authUpload) — Convenience wrapper arounduploadthat automatically attaches the auth token to the request. - Custom auth routes —
Auth.login()andAuth.register()now accept an optionalcustomRouteparameter, enabling projects to override the default auth endpoints. bodyValidationmiddleware exported —bodyValidationis now accessible from the main middleware index.
Improvements
- User model initialization —
firstName,lastName,email, andphoneare now mapped explicitly in theUserconstructor. - Public user payload —
toPublic()now includes derived fieldsfullNameandavatarUrlin the output object. - Session update helper — New
User.updateSession(session)method refreshes the session user data from the latest persisted state.