feat(auth): add dedicated avatar endpoints, session pagination, and audit log idempotency
Summary of Changes
This PR introduces dedicated avatar management endpoints with S3/MinIO cleanup, adds pagination support for active sessions, optimizes audit log creation through idempotency checks, and enhances user projection security.
Key Changes
-
Dedicated Avatar Endpoints:
- Added
PUT /api/v1/auth/avatar: UpdatesavatarUrl,avatarPositionX, andavatarPositionY. - Added
DELETE /api/v1/auth/avatar: Deletes user avatar, resets position to default (50/50), and deletes stored image object viaUploadService.deleteObject. - Decoupled avatar payload from general profile update (
PUT /api/v1/auth/profile).
- Added
-
Session Pagination:
- Updated
GET /api/v1/auth/sessionswithpageandlimitquery validation and standard pagination metadata (meta: { total, page, limit, totalPages }).
- Updated
-
Audit Log Idempotency & Optimization:
- Prevented redundant audit logs in
updateProfile,updateAvatar, andassignPermissionswhen incoming payload matches existing database state.
- Prevented redundant audit logs in
-
Security & Data Projections:
- Added
userSelectmasking across user repository queries to avoid leakingpasswordHashon soft delete and projection updates. - Added
fullNamesupport during admin user creation.
- Added
-
Testing:
- Added comprehensive integration tests covering avatar lifecycle, profile updates, session pagination query validation, and RBAC idempotency.