Files
bookhoard/DOCUMENTATION_UPDATES.md
T
john-okeefe 71584c1b55 feat: Enhance admin user management system
- Add admin override capability to DELETE /api/auth/account endpoint
- Move /api/auth/users to admin-only with complete user fields (first_name, last_name, role, theme)
- Consolidate Bruno requests: remove duplicate List Users (Admin), merge Delete Account functionality
- Update all documentation to reflect enhanced capabilities
- Implement pgx 5 standards compliance with proper error handling

BREAKING CHANGES:
- /api/auth/users endpoint now requires admin role (was previously accessible)
- DELETE /api/auth/account accepts optional user_id parameter for admin deletion
2026-01-27 13:36:11 -05:00

104 lines
4.0 KiB
Markdown

# Documentation Updates Summary
This document summarizes all documentation changes made to keep the codebase consistent with API improvements.
## 🔄 Recent API Consistency Changes
### 1. **Unified API Structure**
- **User Management**: All endpoints now use `/api/auth/*` prefix
- **Library Management**: All endpoints use `/api/library/*` prefix
- **Ebook Folders**: All endpoints use `/api/auth/ebook-folders` (admin-only)
### 2. **Updated Endpoint Mappings**
| Previous | Current | Function |
|----------|---------|----------|
| `/api/user/username` | `/api/auth/username` | Update username |
| `/api/user/email` | `/api/auth/email` | Update email |
| `/api/user/password` | `/api/auth/password` | Update password |
| `/api/user/account` | `/api/auth/account` | Delete account |
### 3. **Enhanced Security Logic**
- **Admin Protection**: Updated deletion logic to prevent deleting last **admin user** (not just last user)
- **More Secure**: Ensures system always has administrative access
## 📝 Updated Documentation Files
### 1. **README.md**
✅ Updated all API endpoint references to use consistent `/api/auth/*` structure
✅ Fixed deletion protection description from "last user" to "last admin"
✅ All endpoint documentation now matches actual implementation
### 2. **bruno/README.md**
✅ Already correctly documented with consistent API structure
✅ Comprehensive API testing documentation maintained
### 3. **bruno/user/Delete Account.bru**
✅ Updated endpoint documentation from `/api/user/account` to `/api/auth/account`
### 4. **Internal Handler Comments** (`internal/handlers/auth.go`)
✅ Updated all handler comment blocks to reference correct endpoints:
- `ListUsers``/api/auth/users`
- `UpdateUsername``/api/auth/username`
- `UpdateEmail``/api/auth/email`
- `UpdatePassword``/api/auth/password`
- `DeleteAccount``/api/auth/account`
### 5. **Template Files** (`templates/admin_profile.templ`)
✅ Updated HTMX form endpoints:
- Username form: `/api/user/username``/api/auth/username`
- Email form: `/api/user/email``/api/auth/email`
- Password form: `/api/user/password``/api/auth/password`
## 🎯 Complete API Documentation
### Authentication (Public)
- `POST /api/auth/register` - Register new user
- `POST /api/auth/login` - Login user
### User Management (Protected)
- `GET /api/auth/profile` - Get user profile
- `PUT /api/auth/profile` - Update profile
- `PUT /api/auth/username` - Update username
- `PUT /api/auth/email` - Update email
- `PUT /api/auth/password` - Update password
- `PUT /api/auth/theme` - Update theme
- `DELETE /api/auth/account` - Delete account ⚠️ *Cannot delete last admin*
### Admin Operations (Admin Only)
- `GET /api/auth/users` - List all users
- `POST /api/auth/ebook-folders` - Add folder
- `GET /api/auth/ebook-folders` - List folders
- `DELETE /api/auth/ebook-folders` - Remove folder
### Library Management (Admin Only)
- `PUT /api/library/scan-settings` - Update scan settings
- `GET /api/library/scan-settings` - Get scan settings
### Ebooks & Progress (All Authenticated Users)
- `GET /api/ebooks` - List ebooks
- `GET /api/ebooks/:id` - Get ebook details
- `GET /api/ebooks/:id/progress` - Get reading progress
- `PUT /api/ebooks/:id/progress` - Update progress
- `GET /api/ebooks/:id/rating` - Get rating
- `POST /api/ebooks/:id/rating` - Create/update rating
- `DELETE /api/ebooks/:id/rating` - Delete rating
- `GET /api/ebooks/:id/ratings` - Get all ratings
## 🔄 Build & Deployment
All changes have been incorporated into the Docker build process:
- Templates are regenerated with `templ generate`
- API consistency is enforced through build process
- Documentation stays in sync with implementation
## 📋 Testing
**Bruno Collection**: All API tests updated to match consistent endpoint structure
**Authentication Flow**: Register → Login → Use Bearer token for protected routes
**Role Testing**: Admin protection verified for critical operations
---
*Last Updated: January 27, 2026*
*API Version: v1 - Consistent Endpoint Structure*