- Add role-based restrictions to POST /api/auth/register endpoint - Only admins can create admin accounts if any admin already exists - First user automatically gets admin role regardless of request - Regular users can only create user accounts, not admin accounts - Unauthenticated users can only create first admin, not subsequent admins - Reorganize Bruno collection into logical subfolders (auth/, admin/, profile/) - Update documentation to reflect new registration restrictions and security rules BREAKING CHANGES: - /api/auth/register now enforces role-based creation restrictions - Bruno collection reorganized with subfolder structure
53 lines
1.3 KiB
Plaintext
53 lines
1.3 KiB
Plaintext
meta {
|
|
name: Delete Account
|
|
type: http
|
|
seq: 4
|
|
}
|
|
|
|
delete {
|
|
url: {{base_url}}/api/auth/account
|
|
body: none
|
|
auth: inherit
|
|
}
|
|
|
|
settings {
|
|
encodeUrl: true
|
|
timeout: 0
|
|
}
|
|
|
|
docs {
|
|
## Delete Account
|
|
|
|
Permanently deletes user account and all associated data.
|
|
|
|
**Method:** DELETE
|
|
|
|
**Endpoint:** /api/auth/account
|
|
|
|
**Authentication:** Required
|
|
|
|
**Usage:**
|
|
- **Self-deletion**: DELETE /api/auth/account (no parameters)
|
|
- **Admin deletion**: DELETE /api/auth/account?user_id={uuid} (admin only)
|
|
|
|
**Query Parameters (Admin only):**
|
|
- `user_id` (string): UUID of user account to delete
|
|
|
|
**Response:**
|
|
- `message` (string): Success message
|
|
|
|
**Status Codes:**
|
|
- 200: Success
|
|
- 400: Bad Request (invalid user_id or attempting to delete last admin)
|
|
- 401: Unauthorized
|
|
- 403: Forbidden (admin access required for user_id parameter)
|
|
- 404: Not Found (user does not exist)
|
|
|
|
**Protection Rules:**
|
|
- Regular users can only delete their own account
|
|
- Admins can delete any account including other users
|
|
- Cannot delete the last admin account in the system
|
|
- Admin role required to use user_id parameter
|
|
|
|
**Warning:** This action cannot be undone and will permanently delete all user data including ebooks, ratings, and progress.
|
|
} |